react-native-nami-sdk 3.0.8 → 3.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.js +12 -0
  3. package/.github/workflows/CI.yaml +610 -0
  4. package/.github/workflows/app_prod.yaml +316 -0
  5. package/.github/workflows/app_stg.yaml +114 -1
  6. package/.pre-commit-config.yaml +0 -1
  7. package/android/build.gradle +2 -2
  8. package/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt +4 -17
  9. package/android/src/main/java/com/nami/reactlibrary/NamiBridgePackage.java +0 -1
  10. package/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt +51 -30
  11. package/android/src/main/java/com/nami/reactlibrary/NamiCustomerManagerBridge.kt +40 -24
  12. package/android/src/main/java/com/nami/reactlibrary/NamiEntitlementManagerBridgeModule.kt +15 -12
  13. package/android/src/main/java/com/nami/reactlibrary/NamiMLManagerBridgeModule.kt +8 -0
  14. package/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt +185 -43
  15. package/android/src/main/java/com/nami/reactlibrary/NamiPurchaseManagerBridge.kt +12 -14
  16. package/android/src/main/java/com/nami/reactlibrary/NamiUtil.kt +3 -47
  17. package/ios/Nami.m +3 -25
  18. package/ios/NamiCampaignManagerBridge.swift +17 -6
  19. package/ios/NamiCustomerManager.m +4 -0
  20. package/ios/NamiCustomerManager.swift +34 -5
  21. package/ios/NamiEntitlementManagerBridge.swift +9 -1
  22. package/ios/NamiMLManagerBridge.m +0 -2
  23. package/ios/NamiPaywallManagerBridge.m +2 -59
  24. package/ios/NamiPaywallManagerBridge.swift +67 -58
  25. package/ios/NamiPurchaseManagerBridge.m +2 -98
  26. package/ios/NamiPurchaseManagerBridge.swift +45 -5
  27. package/ios/RNNami-Bridging-Header.h +0 -1
  28. package/ios/RNNami.xcodeproj/project.pbxproj +2 -67
  29. package/ios/RNNami.xcworkspace/contents.xcworkspacedata +0 -3
  30. package/package.json +14 -4
  31. package/react-native-nami-sdk.podspec +4 -2
  32. package/src/Nami.d.ts +0 -1
  33. package/src/NamiCampaignManager.d.ts +4 -1
  34. package/src/NamiCampaignManager.js +12 -1
  35. package/src/NamiCustomerManager.d.ts +2 -0
  36. package/src/NamiCustomerManager.js +2 -2
  37. package/src/NamiMLManager.d.ts +3 -3
  38. package/src/NamiMLManager.js +1 -1
  39. package/src/NamiPaywallManager.d.ts +27 -21
  40. package/src/NamiPaywallManager.js +21 -7
  41. package/src/NamiPurchaseManager.d.ts +7 -3
  42. package/src/types.ts +10 -3
  43. package/android/src/main/java/com/nami/reactlibrary/NamiEmitter.kt +0 -163
  44. package/ios/NamiBridgeUtil.h +0 -32
  45. package/ios/NamiBridgeUtil.m +0 -231
  46. package/ios/NamiEmitter.m +0 -350
  47. package/ios/Podfile +0 -71
@@ -1,14 +1,11 @@
1
1
  //
2
2
  // NamiPurchaseManagerBridge.m
3
- // namiReactNative
4
3
  //
5
- // Created by Kendall Helmstetter Gelner on 12/11/19.
6
4
  // Copyright © 2019 Nami ML Inc. All rights reserved.
7
5
  //
8
6
 
9
7
  #import <Foundation/Foundation.h>
10
8
  #import <NamiApple/NamiApple.h>
11
- #import "NamiBridgeUtil.h"
12
9
 
13
10
  #import <React/RCTBridgeModule.h>
14
11
  #import <React/RCTEventEmitter.h>
@@ -29,102 +26,9 @@ RCT_EXTERN_METHOD(registerPurchasesChangedHandler)
29
26
 
30
27
  RCT_EXTERN_METHOD(registerRestorePurchasesHandler)
31
28
 
32
- + (BOOL)requiresMainQueueSetup {
33
- return YES;
34
- }
35
-
36
- @end
37
-
38
- @interface NamiEmitter : RCTEventEmitter
39
- - (void)sendRestorePurchasesStateChanged: (enum NamiRestorePurchasesState) state
40
- newPurchases: (NSArray<NamiPurchase *> * _Nonnull) newPurchases
41
- oldPurchases: (NSArray<NamiPurchase *> * _Nonnull) oldPurchases
42
- error: (NSError * _Nullable) error;
43
- - (NSDictionary *)buildRestorePurchasesStateChangedDict: (enum NamiRestorePurchasesState) state
44
- newPurchases: (NSArray<NamiPurchase *> * _Nonnull) newPurchases
45
- oldPurchases: (NSArray<NamiPurchase *> * _Nonnull) oldPurchases
46
- error: (NSError * _Nullable) error;
47
- + (NamiEmitter *) reactInstance;
48
- @end
49
-
50
- @interface NamiPurchaseManagerBridge : NSObject <RCTBridgeModule>
51
- @end
52
- @implementation NamiPurchaseManagerBridge (RCTExternModule)
53
-
54
-
55
- RCT_EXTERN_METHOD(clearBypassStorePurchases)
56
- - (void)clearBypassStorePurchases {
57
- [NamiPurchaseManager clearBypassStorePurchases];
58
- }
59
-
60
-
61
- RCT_EXPORT_METHOD(restorePurchasesWithCompletionHandler:(RCTResponseSenderBlock)completion)
62
- {
63
- NSLog(@"NamiBridge: Info: Calling RestorePurchasesWithCompletionHandler");
64
-
65
- [NamiPurchaseManager restorePurchasesWithStatehandler:^(enum NamiRestorePurchasesState state, NSArray<NamiPurchase *> * _Nonnull newPurchases, NSArray<NamiPurchase *> * _Nonnull oldPurchases, NSError * _Nullable error) {
66
- NSDictionary *retDict = [[NamiEmitter reactInstance] buildRestorePurchasesStateChangedDict:state newPurchases:newPurchases oldPurchases:oldPurchases error:error];
67
- completion(@[retDict]);
68
- }];
69
- }
70
-
71
- RCT_EXPORT_METHOD(restorePurchases)
72
- {
73
- NSLog(@"NamiBridge: Info: Calling RestorePurchases");
74
-
75
- [NamiPurchaseManager restorePurchasesWithStatehandler:^(enum NamiRestorePurchasesState state, NSArray<NamiPurchase *> * _Nonnull newPurchases, NSArray<NamiPurchase *> * _Nonnull oldPurchases, NSError * _Nullable error) {
76
- [[NamiEmitter reactInstance] sendRestorePurchasesStateChanged:state newPurchases:newPurchases oldPurchases:oldPurchases error:error];
77
- }];
78
- }
29
+ RCT_EXTERN_METHOD(presentCodeRedemptionSheet)
79
30
 
80
-
81
- /// For consumable purchases, removes the SKU from Nami so a product may be purchased again.
82
- RCT_EXPORT_METHOD(presentCodeRedemptionSheet)
83
- {
84
- if (@available(iOS 14.0, *)) {
85
- [NamiPurchaseManager presentCodeRedemptionSheet];
86
- } else {
87
- NSLog(@"NamiBridge: Warning: presentCodeRedemptionSheet only present in iOS14 and higher");
88
- }
89
- }
90
-
91
- RCT_EXPORT_METHOD(canPresentCodeRedemptionSheet:(RCTResponseSenderBlock)completion)
92
- {
93
- if (@available(iOS 14.0, *)) {
94
- completion(@[[NSNumber numberWithBool:true]]);
95
- } else {
96
- completion(@[[NSNumber numberWithBool:false]]);
97
- }
98
- }
99
-
100
- /// This method does the purchase work, and can optionally be fed a paywall metadata object to pass along to the purchase flow.
101
- //- (void) doSKUPurchaseWithSKUID:(nonnull NSString*)skuID namiPaywall:(NamiPaywall * _Nullable)namiPaywall completion:(RCTResponseSenderBlock)completion {
102
- // [NamiPurchaseManager skusForSKUIdsWithSkuIds:@[skuID] productHandler:^(BOOL success, NSArray<NamiSKU *> * _Nullable products, NSArray<NSString *> * _Nullable invalidProducts, NSError * _Nullable error) {
103
- // NSLog(@"NamiBridge: Info: Products found are %@, product fetch error is %@", products, [error localizedDescription]);
104
- // NamiSKU *useProduct = products.firstObject;
105
- // if (useProduct != nil) {
106
- // [NamiPurchaseManager buySku:useProduct responseHandler:^(NSArray<NamiPurchase *> * _Nonnull purchase, enum NamiPurchaseState purchaseState, NSError * _Nullable error) {
107
- // NSLog(@"NamiBridge: Info: Purchase result is %@, purchased is %d, purchaseState is %@, error is %@", purchase, (purchaseState == NamiPurchaseStatePurchased), [NSNumber numberWithInt:(int)purchaseState], [error localizedDescription]);
108
- // if (purchaseState == NamiPurchaseStatePurchased) {
109
- // completion(@[[NSNumber numberWithBool:true]]);
110
- // }
111
- // }];
112
- // } else {
113
- // completion(@[[NSNumber numberWithBool:false]]);
114
- // }
115
- // }];
116
- //
117
- //}
118
-
119
- @end
120
-
121
- @implementation NamiPurchaseManagerBridge
122
- RCT_EXPORT_MODULE_NO_LOAD(NamiPurchaseManagerBridge, NamiPurchaseManagerBridge)
123
-
124
- - (dispatch_queue_t)methodQueue
125
- {
126
- return dispatch_get_main_queue();
127
- }
31
+ RCT_EXTERN_METHOD(restorePurchases)
128
32
 
129
33
  + (BOOL)requiresMainQueueSetup {
130
34
  return YES;
@@ -11,6 +11,13 @@ import React
11
11
 
12
12
  @objc(RNNamiPurchaseManager)
13
13
  class RNNamiPurchaseManager: RCTEventEmitter {
14
+ public static var shared: RNNamiPurchaseManager?
15
+
16
+ override init() {
17
+ super.init()
18
+ RNNamiPurchaseManager.shared = self
19
+ }
20
+
14
21
  override func supportedEvents() -> [String]! {
15
22
  return ["PurchasesChanged", "RestorePurchasesStateChanged"]
16
23
  }
@@ -47,12 +54,10 @@ class RNNamiPurchaseManager: RCTEventEmitter {
47
54
  }
48
55
 
49
56
  let skuDict: [String: Any?] = [
50
- "name": sku.name,
57
+ "id": sku.id,
51
58
  "skuId": sku.skuId,
52
59
  "type": typeString,
53
- "product": productDict,
54
- // "displayText": sku.localizedDisplayText,
55
- // "displaySubText": sku.localizedSubDisplayText,
60
+ "appleProduct": productDict,
56
61
  ]
57
62
 
58
63
  return NSDictionary(dictionary: skuDict.compactMapValues { $0 })
@@ -68,6 +73,7 @@ class RNNamiPurchaseManager: RCTEventEmitter {
68
73
  dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
69
74
  let expiresString = dateFormatter.string(from: purchase.expires ?? Date())
70
75
  let purchaseInitiatedString = dateFormatter.string(from: purchase.purchaseInitiatedTimestamp)
76
+
71
77
  let purchaseDict: [String: Any?] = [
72
78
  "skuId": purchase.skuId,
73
79
  "transactionIdentifier": purchase.transactionIdentifier,
@@ -168,7 +174,41 @@ class RNNamiPurchaseManager: RCTEventEmitter {
168
174
  "newPurchases": newPurchasesDictionaries,
169
175
  "oldPurchases": oldPurchasesDictionaries,
170
176
  ]
171
- self.sendEvent(withName: "RestorePurchasesStateChanged", body: payload)
177
+ RNNamiPurchaseManager.shared?.sendEvent(withName: "RestorePurchasesStateChanged", body: payload)
172
178
  }
173
179
  }
180
+
181
+ @objc(restorePurchases)
182
+ func restorePurchases() {
183
+ NamiPurchaseManager.restorePurchases { state, newPurchases, oldPurchases, _ in
184
+ let stateString: String
185
+ switch state {
186
+ case .started:
187
+ stateString = "started"
188
+ case .finished:
189
+ stateString = "finished"
190
+ case .error:
191
+ stateString = "error"
192
+ @unknown default:
193
+ stateString = "error"
194
+ }
195
+ let newPurchasesDictionaries = newPurchases.map { purchase in
196
+ RNNamiPurchaseManager.purchaseToPurchaseDict(purchase)
197
+ }
198
+ let oldPurchasesDictionaries = oldPurchases.map { purchase in
199
+ RNNamiPurchaseManager.purchaseToPurchaseDict(purchase)
200
+ }
201
+ let payload: [String: Any?] = [
202
+ "state": stateString,
203
+ "newPurchases": newPurchasesDictionaries,
204
+ "oldPurchases": oldPurchasesDictionaries,
205
+ ]
206
+ RNNamiPurchaseManager.shared?.sendEvent(withName: "RestorePurchasesStateChanged", body: payload)
207
+ }
208
+ }
209
+
210
+ @objc(presentCodeRedemptionSheet)
211
+ func presentCodeRedemptionSheet() {
212
+ NamiPurchaseManager.presentCodeRedemptionSheet()
213
+ }
174
214
  }
@@ -2,4 +2,3 @@
2
2
  // Use this file to import your target's public headers that you would like to expose to Swift.
3
3
  //
4
4
  #import <React/RCTBridgeModule.h>
5
- #import "NamiBridgeUtil.h"
@@ -7,7 +7,6 @@
7
7
  objects = {
8
8
 
9
9
  /* Begin PBXBuildFile section */
10
- 86FA58043F9BC23498A02E29 /* libPods-RNNami.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D38955F0C8C312F217C02595 /* libPods-RNNami.a */; };
11
10
  B3E7B58A1CC2AC0600A0062D /* RNNami.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RNNami.m */; };
12
11
  EB1C9AFB23BE9C5700CAD548 /* NamiPurchaseManagerBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = EB1C9AF823BE9C5600CAD548 /* NamiPurchaseManagerBridge.m */; };
13
12
  EB1C9AFC23BE9C5700CAD548 /* NamiPaywallManagerBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = EB1C9AF923BE9C5600CAD548 /* NamiPaywallManagerBridge.m */; };
@@ -15,7 +14,6 @@
15
14
  EB75992124F031E900430D98 /* NamiCustomerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = EB75992024F031E900430D98 /* NamiCustomerManager.m */; };
16
15
  EB7B50CE243E314900EBA6B7 /* NamiEntitlementManagerBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = EB7B50CD243E314900EBA6B7 /* NamiEntitlementManagerBridge.m */; };
17
16
  EBC59E5D23C5514B008A123A /* Nami.m in Sources */ = {isa = PBXBuildFile; fileRef = EBC59E5C23C5514B008A123A /* Nami.m */; };
18
- EBC59E6023C7E2EC008A123A /* NamiAnalyticsEmitter.m in Sources */ = {isa = PBXBuildFile; fileRef = EBC59E5F23C7E2EC008A123A /* NamiAnalyticsEmitter.m */; };
19
17
  EBC59E6323C7F634008A123A /* NamiBridgeUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = EBC59E6223C7F634008A123A /* NamiBridgeUtil.m */; };
20
18
  EBEEAC10243C29C800E01389 /* NamiMLManagerBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = EBEEAC0F243C29C800E01389 /* NamiMLManagerBridge.m */; };
21
19
  FA3AB38529E009F300FD2E8D /* NamiPaywallManagerBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA3AB38429E009F300FD2E8D /* NamiPaywallManagerBridge.swift */; };
@@ -39,19 +37,15 @@
39
37
  /* End PBXCopyFilesBuildPhase section */
40
38
 
41
39
  /* Begin PBXFileReference section */
42
- 134814201AA4EA6300B7C361 /* libRNNami.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNNami.a; sourceTree = BUILT_PRODUCTS_DIR; };
43
- 5C0ED6F1EABFB69B20A67C29 /* Pods-RNNami.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNNami.debug.xcconfig"; path = "Target Support Files/Pods-RNNami/Pods-RNNami.debug.xcconfig"; sourceTree = "<group>"; };
44
- 90B290F36EAE177CDC017BA3 /* Pods-RNNami.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNNami.release.xcconfig"; path = "Target Support Files/Pods-RNNami/Pods-RNNami.release.xcconfig"; sourceTree = "<group>"; };
40
+ 134814201AA4EA6300B7C361 /* libRNNami.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; name = libRNNami.a; path = "/Users/dannami/Nami/Source/react-native-nami-sdk/ios/build/Debug-iphoneos/libRNNami.a"; sourceTree = "<absolute>"; };
45
41
  B3E7B5881CC2AC0600A0062D /* RNNami.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNami.h; sourceTree = "<group>"; };
46
42
  B3E7B5891CC2AC0600A0062D /* RNNami.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNami.m; sourceTree = "<group>"; };
47
- D38955F0C8C312F217C02595 /* libPods-RNNami.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNNami.a"; sourceTree = BUILT_PRODUCTS_DIR; };
48
43
  EB1C9AF823BE9C5600CAD548 /* NamiPurchaseManagerBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NamiPurchaseManagerBridge.m; sourceTree = "<group>"; };
49
44
  EB1C9AF923BE9C5600CAD548 /* NamiPaywallManagerBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NamiPaywallManagerBridge.m; sourceTree = "<group>"; };
50
45
  EB1C9AFA23BE9C5700CAD548 /* NamiEmitter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NamiEmitter.m; sourceTree = "<group>"; };
51
46
  EB75992024F031E900430D98 /* NamiCustomerManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NamiCustomerManager.m; sourceTree = "<group>"; };
52
47
  EB7B50CD243E314900EBA6B7 /* NamiEntitlementManagerBridge.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NamiEntitlementManagerBridge.m; sourceTree = "<group>"; };
53
48
  EBC59E5C23C5514B008A123A /* Nami.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Nami.m; sourceTree = "<group>"; };
54
- EBC59E5F23C7E2EC008A123A /* NamiAnalyticsEmitter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NamiAnalyticsEmitter.m; sourceTree = "<group>"; };
55
49
  EBC59E6223C7F634008A123A /* NamiBridgeUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NamiBridgeUtil.m; sourceTree = "<group>"; };
56
50
  EBC59E6423C7F7A0008A123A /* NamiBridgeUtil.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NamiBridgeUtil.h; sourceTree = "<group>"; };
57
51
  EBEEAC0F243C29C800E01389 /* NamiMLManagerBridge.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NamiMLManagerBridge.m; sourceTree = "<group>"; };
@@ -69,21 +63,12 @@
69
63
  isa = PBXFrameworksBuildPhase;
70
64
  buildActionMask = 2147483647;
71
65
  files = (
72
- 86FA58043F9BC23498A02E29 /* libPods-RNNami.a in Frameworks */,
73
66
  );
74
67
  runOnlyForDeploymentPostprocessing = 0;
75
68
  };
76
69
  /* End PBXFrameworksBuildPhase section */
77
70
 
78
71
  /* Begin PBXGroup section */
79
- 134814211AA4EA7D00B7C361 /* Products */ = {
80
- isa = PBXGroup;
81
- children = (
82
- 134814201AA4EA6300B7C361 /* libRNNami.a */,
83
- );
84
- name = Products;
85
- sourceTree = "<group>";
86
- };
87
72
  58B511D21A9E6C8500147676 = {
88
73
  isa = PBXGroup;
89
74
  children = (
@@ -99,29 +84,8 @@
99
84
  B3E7B5891CC2AC0600A0062D /* RNNami.m */,
100
85
  EBC59E5C23C5514B008A123A /* Nami.m */,
101
86
  EB1C9AFA23BE9C5700CAD548 /* NamiEmitter.m */,
102
- EBC59E5F23C7E2EC008A123A /* NamiAnalyticsEmitter.m */,
103
87
  EBEEAC0F243C29C800E01389 /* NamiMLManagerBridge.m */,
104
- 134814211AA4EA7D00B7C361 /* Products */,
105
- 82475599A9F3B58440ACDC6E /* Frameworks */,
106
- A17A44E9FF56BDEADE788165 /* Pods */,
107
- );
108
- sourceTree = "<group>";
109
- };
110
- 82475599A9F3B58440ACDC6E /* Frameworks */ = {
111
- isa = PBXGroup;
112
- children = (
113
- D38955F0C8C312F217C02595 /* libPods-RNNami.a */,
114
- );
115
- name = Frameworks;
116
- sourceTree = "<group>";
117
- };
118
- A17A44E9FF56BDEADE788165 /* Pods */ = {
119
- isa = PBXGroup;
120
- children = (
121
- 5C0ED6F1EABFB69B20A67C29 /* Pods-RNNami.debug.xcconfig */,
122
- 90B290F36EAE177CDC017BA3 /* Pods-RNNami.release.xcconfig */,
123
88
  );
124
- path = Pods;
125
89
  sourceTree = "<group>";
126
90
  };
127
91
  FA3AB38329E009D200FD2E8D /* NamiPaywallManager */ = {
@@ -176,7 +140,6 @@
176
140
  isa = PBXNativeTarget;
177
141
  buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNNami" */;
178
142
  buildPhases = (
179
- D4E4645754B75DF6DB7C7A3E /* [CP] Check Pods Manifest.lock */,
180
143
  58B511D71A9E6C8500147676 /* Sources */,
181
144
  58B511D81A9E6C8500147676 /* Frameworks */,
182
145
  58B511D91A9E6C8500147676 /* CopyFiles */,
@@ -223,38 +186,12 @@
223
186
  };
224
187
  /* End PBXProject section */
225
188
 
226
- /* Begin PBXShellScriptBuildPhase section */
227
- D4E4645754B75DF6DB7C7A3E /* [CP] Check Pods Manifest.lock */ = {
228
- isa = PBXShellScriptBuildPhase;
229
- buildActionMask = 2147483647;
230
- files = (
231
- );
232
- inputFileListPaths = (
233
- );
234
- inputPaths = (
235
- "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
236
- "${PODS_ROOT}/Manifest.lock",
237
- );
238
- name = "[CP] Check Pods Manifest.lock";
239
- outputFileListPaths = (
240
- );
241
- outputPaths = (
242
- "$(DERIVED_FILE_DIR)/Pods-RNNami-checkManifestLockResult.txt",
243
- );
244
- runOnlyForDeploymentPostprocessing = 0;
245
- shellPath = /bin/sh;
246
- shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
247
- showEnvVarsInLog = 0;
248
- };
249
- /* End PBXShellScriptBuildPhase section */
250
-
251
189
  /* Begin PBXSourcesBuildPhase section */
252
190
  58B511D71A9E6C8500147676 /* Sources */ = {
253
191
  isa = PBXSourcesBuildPhase;
254
192
  buildActionMask = 2147483647;
255
193
  files = (
256
194
  FA3AB38529E009F300FD2E8D /* NamiPaywallManagerBridge.swift in Sources */,
257
- EBC59E6023C7E2EC008A123A /* NamiAnalyticsEmitter.m in Sources */,
258
195
  EBC59E5D23C5514B008A123A /* Nami.m in Sources */,
259
196
  EB1C9AFB23BE9C5700CAD548 /* NamiPurchaseManagerBridge.m in Sources */,
260
197
  EB1C9AFC23BE9C5700CAD548 /* NamiPaywallManagerBridge.m in Sources */,
@@ -297,7 +234,7 @@
297
234
  COPY_PHASE_STRIP = NO;
298
235
  ENABLE_STRICT_OBJC_MSGSEND = YES;
299
236
  ENABLE_TESTABILITY = YES;
300
- "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
237
+ "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 ";
301
238
  GCC_C_LANGUAGE_STANDARD = gnu99;
302
239
  GCC_DYNAMIC_NO_PIC = NO;
303
240
  GCC_NO_COMMON_BLOCKS = YES;
@@ -360,7 +297,6 @@
360
297
  };
361
298
  58B511F01A9E6C8500147676 /* Debug */ = {
362
299
  isa = XCBuildConfiguration;
363
- baseConfigurationReference = 5C0ED6F1EABFB69B20A67C29 /* Pods-RNNami.debug.xcconfig */;
364
300
  buildSettings = {
365
301
  CLANG_ENABLE_MODULES = YES;
366
302
  HEADER_SEARCH_PATHS = (
@@ -383,7 +319,6 @@
383
319
  };
384
320
  58B511F11A9E6C8500147676 /* Release */ = {
385
321
  isa = XCBuildConfiguration;
386
- baseConfigurationReference = 90B290F36EAE177CDC017BA3 /* Pods-RNNami.release.xcconfig */;
387
322
  buildSettings = {
388
323
  CLANG_ENABLE_MODULES = YES;
389
324
  HEADER_SEARCH_PATHS = (
@@ -4,7 +4,4 @@
4
4
  <FileRef
5
5
  location = "group:RNNami.xcodeproj">
6
6
  </FileRef>
7
- <FileRef
8
- location = "group:Pods/Pods.xcodeproj">
9
- </FileRef>
10
7
  </Workspace>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nami-sdk",
3
- "version": "3.0.8",
3
+ "version": "3.0.10",
4
4
  "description": "React Native Module for Nami - Easy subscriptions & in-app purchases, with powerful built-in paywalls and A/B testing.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -41,14 +41,24 @@
41
41
  }
42
42
  ],
43
43
  "license": "SEE LICENSE FILE",
44
+ "standard": {
45
+ "ignore": [
46
+ "examples/*"
47
+ ]
48
+ },
44
49
  "peerDependencies": {
45
- "react": "^17.0.2",
46
- "react-native": "^0.65.2"
50
+ "react": ">=17",
51
+ "react-native": ">=0.65"
47
52
  },
48
53
  "devDependencies": {
54
+ "@react-native-community/eslint-config": "^3.2.0",
55
+ "@typescript-eslint/eslint-plugin": "^5.59.7",
56
+ "eslint": "^8.41.0",
57
+ "prettier": "^2.8.7",
49
58
  "react": "^17.0.2",
50
59
  "react-native": "^0.65.2",
51
- "react-native-codegen": "^0.0.12"
60
+ "react-native-codegen": "^0.0.12",
61
+ "typescript": "^5.0.2"
52
62
  },
53
63
  "repository": {
54
64
  "type": "git",
@@ -13,12 +13,14 @@ Pod::Spec.new do |s|
13
13
  s.homepage = package['homepage']
14
14
  s.license = package['license']
15
15
 
16
- s.platform = :ios, "14.0"
16
+ s.platforms = { :ios => "14.0", :tvos => "15.0" }
17
+
18
+
17
19
  s.source = { :git => "https://github.com/namiml/react-native-nami-sdk.git", :tag => "#{s.version}" }
18
20
  s.source_files = "ios/**/*.{h,m,swift}"
19
21
  s.requires_arc = true
20
22
 
21
- s.dependency 'Nami', '3.0.8'
23
+ s.dependency 'Nami', '3.0.13'
22
24
  s.dependency 'React'
23
25
 
24
26
  end
package/src/Nami.d.ts CHANGED
@@ -10,7 +10,6 @@ export type NamiConfiguration = {
10
10
  "appPlatformID-android": string;
11
11
  logLevel: string;
12
12
  namiLanguageCode?: NamiLanguageCodes;
13
- bypassStore?: boolean;
14
13
  };
15
14
 
16
15
  export type NamiLanguageCodes =
@@ -12,7 +12,10 @@ export const NamiCampaignManager: {
12
12
  action: NamiPaywallAction,
13
13
  skuId?: string,
14
14
  purchaseError?: string,
15
- purchases?: NamiPurchase[]
15
+ purchases?: NamiPurchase[],
16
+ campaignId?: string,
17
+ campaignLabel?: string,
18
+ paywallId?: string
16
19
  ) => void
17
20
  ) => void;
18
21
  refresh: () => void;
@@ -20,7 +20,18 @@ export const NamiCampaignManager = {
20
20
  var skuId = body.skuId;
21
21
  var purchaseError = body.purchaseError;
22
22
  var purchases = body.purchases;
23
- actionCallback(action, skuId, purchaseError, purchases);
23
+ var campaignId = body.campaignId;
24
+ var campaignLabel = body.campaignLabel;
25
+ var paywallId = body.paywallId;
26
+ actionCallback(
27
+ action,
28
+ skuId,
29
+ purchaseError,
30
+ purchases,
31
+ campaignId,
32
+ campaignLabel,
33
+ paywallId
34
+ );
24
35
  }
25
36
  );
26
37
  RNNamiCampaignManager.launch(
@@ -24,6 +24,8 @@ export const NamiCustomerManager: {
24
24
  error?: number
25
25
  ) => void
26
26
  ) => EmitterSubscription["remove"];
27
+ clearCustomerDataPlatformId: () => void;
28
+ setCustomerDataPlatformId: (platformId: string) => void;
27
29
  };
28
30
 
29
31
  export type CustomerJourneyState = {
@@ -6,14 +6,14 @@ export const NamiCustomerManager = {
6
6
  emitter: new NativeEventEmitter(RNNamiCustomerManager),
7
7
  ...RNNamiCustomerManager,
8
8
  login: (customerId, callback) => {
9
- if (Platform.OS === "ios") {
9
+ if (Platform.OS === "ios" || Platform.isTVOS) {
10
10
  RNNamiCustomerManager.login(customerId, callback ?? (() => {}));
11
11
  } else {
12
12
  RNNamiCustomerManager.login(customerId);
13
13
  }
14
14
  },
15
15
  logout: (callback) => {
16
- if (Platform.OS === "ios") {
16
+ if (Platform.OS === "ios" || Platform.isTVOS) {
17
17
  RNNamiCustomerManager.logout(callback ?? (() => {}));
18
18
  } else {
19
19
  RNNamiCustomerManager.logout();
@@ -1,5 +1,5 @@
1
1
  export const NamiMLManager: {
2
- coreAction: (label: string) => void;
3
- enterCoreContent: (label: string | string[]) => void;
4
- exitCoreContent: (label: string | string[]) => void;
2
+ coreAction: (label: string) => void;
3
+ enterCoreContent: (label: string | string[]) => void;
4
+ exitCoreContent: (label: string | string[]) => void;
5
5
  };
@@ -3,5 +3,5 @@ import { NativeModules } from "react-native";
3
3
  export const { NamiMLManagerBridge } = NativeModules;
4
4
 
5
5
  export const NamiMLManager = {
6
- ...NamiMLManagerBridge
6
+ ...NamiMLManagerBridge,
7
7
  };
@@ -2,21 +2,20 @@ import { EmitterSubscription } from "react-native";
2
2
  import { NamiSKU } from "./types";
3
3
 
4
4
  export const NamiPaywallManager: {
5
- buySkuComplete: (purchaseSuccess: PurchaseSuccess) => void;
6
- dismiss: (animated: boolean, callback: () => void) => void;
7
- displayedViewController: () => void;
8
- renderCustomUiHandler: () => any;
5
+ buySkuCompleteApple: (purchaseSuccess: NamiPurchaseSuccessApple) => void;
6
+ buySkuCompleteAmazon: (purchaseSuccess: NamiPurchaseSuccessAmazon) => void;
7
+ buySkuCompleteGooglePlay: (
8
+ purchaseSuccess: NamiPurchaseSuccessGooglePlay
9
+ ) => void;
10
+ dismiss: (animated?: boolean) => void;
9
11
  registerBuySkuHandler: (
10
12
  callback: (sku: NamiSKU) => void
11
13
  ) => EmitterSubscription["remove"];
12
- registerCloseHandler: (
13
- blockDismiss: boolean,
14
- callback: (resultObject: { blockingPaywallClosed: boolean }) => void
15
- ) => EmitterSubscription["remove"];
14
+ registerCloseHandler: (callback: () => void) => EmitterSubscription["remove"];
16
15
  };
17
16
 
18
- export type PurchaseSuccess = {
19
- product: PurchaseSuccessProduct;
17
+ export type NamiPurchaseSuccessApple = {
18
+ product: NamiSKU;
20
19
  transactionID: string;
21
20
  originalTransactionID: string;
22
21
  originalPurchaseDate: number;
@@ -27,17 +26,24 @@ export type PurchaseSuccess = {
27
26
  locale: string;
28
27
  };
29
28
 
30
- export type PurchaseSuccessProduct = {
31
- id: string;
32
- platformID: string;
33
- skuId: string;
34
- languageCode: string;
35
- name: string;
36
- featured: boolean;
37
- storeId: string;
38
- type: number;
39
- isFeatured: boolean;
40
- namiID: string;
29
+ export type NamiPurchaseSuccessGooglePlay = {
30
+ product: NamiSKU;
31
+ orderId: string;
32
+ purchaseDate: number;
33
+ expiresDate?: number;
34
+ purchaseToken: string;
35
+ purchaseSource: "CAMPAIGN" | "MARKETPLACE" | "UNKNOWN";
36
+ };
37
+
38
+ export type NamiPurchaseSuccessAmazon = {
39
+ product: NamiSKU;
40
+ purchaseDate: number;
41
+ expiresDate?: number;
42
+ purchaseSource: "CAMPAIGN" | "MARKETPLACE" | "UNKNOWN";
43
+ receiptId: string;
44
+ localizedPrice: string;
45
+ userId: string;
46
+ marketplace: string;
41
47
  };
42
48
 
43
49
  export enum NamiPaywallAction {
@@ -6,23 +6,37 @@ export const NamiPaywallManager = {
6
6
  paywallEmitter: new NativeEventEmitter(RNNamiPaywallManager),
7
7
  ...RNNamiPaywallManager,
8
8
  ...NamiPaywallManagerBridge,
9
+ buySkuCompleteApple(purchaseSuccess) {
10
+ RNNamiPaywallManager.buySkuComplete(purchaseSuccess);
11
+ },
12
+ buySkuCompleteAmazon(purchaseSuccess) {
13
+ RNNamiPaywallManager.buySkuComplete(purchaseSuccess, "Amazon");
14
+ },
15
+ buySkuCompleteGooglePlay(purchaseSuccess) {
16
+ RNNamiPaywallManager.buySkuComplete(purchaseSuccess, "GooglePlay");
17
+ },
9
18
  registerBuySkuHandler(callback) {
10
19
  var subscription = this.paywallEmitter.addListener(
11
20
  "RegisterBuySKU",
12
- callback
21
+ (sku) => {
22
+ callback(sku);
23
+ }
13
24
  );
14
25
  RNNamiPaywallManager.registerBuySkuHandler();
15
26
  return subscription.remove;
16
27
  },
17
- registerCloseHandler(blockDismiss, callback) {
28
+ registerCloseHandler(callback) {
18
29
  var subscription;
19
30
  subscription = this.paywallEmitter.addListener(
20
- "BlockingPaywallClosed",
21
- () => {
22
- subscription.remove();
23
- callback();
31
+ "PaywallCloseRequested",
32
+ (body) => {
33
+ callback(body);
24
34
  }
25
35
  );
26
- RNNamiPaywallManager.registerCloseHandler(blockDismiss);
36
+ RNNamiPaywallManager.registerCloseHandler();
37
+ return subscription.remove;
38
+ },
39
+ dismiss(animated) {
40
+ RNNamiPaywallManager.dismiss(animated ?? true);
27
41
  },
28
42
  };
@@ -1,14 +1,18 @@
1
1
  import { EmitterSubscription } from "react-native";
2
2
  import { NamiSKU } from "./types";
3
- import { NamiEntitlement } from "./NamiEntitlementManager";
4
3
 
5
4
  export const NamiPurchaseManager: {
6
5
  allPurchases: () => NamiPurchase[];
7
6
  anySkuPurchased: (skuIds: string[]) => boolean;
8
7
  consumePurchasedSku: (skuId: string) => void;
9
- clearBypassStorePurchases: () => void;
10
8
  presentCodeRedemptionSheet: () => void;
11
- restorePurchases: () => void;
9
+ restorePurchases: (
10
+ callback: (
11
+ purchaseState: NamiPurchasesState,
12
+ purchases: NamiPurchase[],
13
+ error: string
14
+ ) => void
15
+ ) => EmitterSubscription["remove"];
12
16
  skuPurchased: (skuId: string) => boolean;
13
17
  registerPurchasesChangedHandler: (
14
18
  callback: (