react-native-nami-sdk 2.0.4 → 2.0.5
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.
- package/.github/workflows/build.yml +2 -2
- package/.pre-commit-config.yaml +25 -0
- package/android/src/main/java/com/nami/reactlibrary/Constants.kt +1 -1
- package/android/src/main/java/com/nami/reactlibrary/NamiAnalyticsEmitter.kt +1 -1
- package/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt +1 -1
- package/android/src/main/java/com/nami/reactlibrary/NamiBridgePackage.java +0 -3
- package/android/src/main/java/com/nami/reactlibrary/NamiCustomerManagerBridge.kt +1 -1
- package/android/src/main/java/com/nami/reactlibrary/NamiEmitter.kt +1 -1
- package/android/src/main/java/com/nami/reactlibrary/NamiEntitlementManagerBridgeModule.kt +1 -1
- package/android/src/main/java/com/nami/reactlibrary/NamiMLManagerBridgeModule.kt +1 -1
- package/android/src/main/java/com/nami/reactlibrary/NamiPurchaseManagerBridge.kt +1 -1
- package/ios/Nami.m +17 -17
- package/ios/NamiAnalyticsEmitter.m +1 -1
- package/ios/NamiBridgeUtil.m +33 -33
- package/ios/NamiCustomerManager.m +1 -1
- package/ios/NamiEmitter.m +37 -37
- package/ios/NamiEntitlementManagerBridge.m +11 -11
- package/ios/NamiPaywallManagerBridge.m +5 -5
- package/ios/NamiPurchaseManagerBridge.m +5 -5
- package/ios/RNNami.h +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/mirrors-eslint
|
|
3
|
+
rev: v8.8.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: eslint
|
|
6
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
7
|
+
rev: v2.3.0
|
|
8
|
+
hooks:
|
|
9
|
+
- id: check-added-large-files
|
|
10
|
+
- id: check-json
|
|
11
|
+
- id: check-merge-conflict
|
|
12
|
+
- id: check-symlinks
|
|
13
|
+
- id: check-yaml
|
|
14
|
+
args: [--allow-multiple-documents]
|
|
15
|
+
- id: end-of-file-fixer
|
|
16
|
+
- id: trailing-whitespace
|
|
17
|
+
exclude: ^.*\b(\.(js|jsx|tsx).snap)\b$
|
|
18
|
+
- repo: https://github.com/nicklockwood/SwiftFormat
|
|
19
|
+
rev: 0.50.8
|
|
20
|
+
hooks:
|
|
21
|
+
- id: swiftformat
|
|
22
|
+
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
|
|
23
|
+
rev: v2.6.0
|
|
24
|
+
hooks:
|
|
25
|
+
- id: pretty-format-kotlin
|
|
@@ -128,7 +128,7 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
128
128
|
} else {
|
|
129
129
|
Arguments.createArray()
|
|
130
130
|
}
|
|
131
|
-
val settingsList = mutableListOf("extendedClientInfo:react-native:2.0.
|
|
131
|
+
val settingsList = mutableListOf("extendedClientInfo:react-native:2.0.5")
|
|
132
132
|
namiCommandsReact?.toArrayList()?.filterIsInstance<String>()?.let { commandsFromReact ->
|
|
133
133
|
settingsList.addAll(commandsFromReact)
|
|
134
134
|
}
|
package/ios/Nami.m
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
// Nami.m
|
|
3
3
|
// RNNami
|
|
4
4
|
//
|
|
5
|
-
//
|
|
6
|
-
// Copyright © 2020 Nami ML Inc. All rights reserved.
|
|
5
|
+
// Copyright © 2020-2023 Nami ML Inc. All rights reserved.
|
|
7
6
|
//
|
|
8
7
|
|
|
9
8
|
#import <Foundation/Foundation.h>
|
|
@@ -25,10 +24,10 @@ RCT_EXPORT_METHOD(configure: (NSDictionary *)configDict) {
|
|
|
25
24
|
NSLog(@"Configure dictionary is %@", configDict);
|
|
26
25
|
}
|
|
27
26
|
NSString *appID = configDict[@"appPlatformID-apple"];
|
|
28
|
-
|
|
27
|
+
|
|
29
28
|
if ([appID length] > 0 ) {
|
|
30
29
|
NamiConfiguration *config = [NamiConfiguration configurationForAppPlatformID:appID];
|
|
31
|
-
|
|
30
|
+
|
|
32
31
|
NSString *logLevelString = configDict[@"logLevel"];
|
|
33
32
|
if ([logLevelString isEqualToString:@"ERROR" ]) {
|
|
34
33
|
config.logLevel = NamiLogLevelError;
|
|
@@ -40,7 +39,7 @@ RCT_EXPORT_METHOD(configure: (NSDictionary *)configDict) {
|
|
|
40
39
|
// If they messed up the params, just set logging to full.
|
|
41
40
|
config.logLevel = NamiLogLevelDebug;
|
|
42
41
|
}
|
|
43
|
-
|
|
42
|
+
|
|
44
43
|
NSString *languageString = configDict[@"namiLanguageCode"];
|
|
45
44
|
if ([logLevelString length] > 0) {
|
|
46
45
|
NSLog(@"Nami language code from config dictionary is %@", languageString);
|
|
@@ -51,7 +50,7 @@ RCT_EXPORT_METHOD(configure: (NSDictionary *)configDict) {
|
|
|
51
50
|
NSLog(@"Warning: Nami language code from config dictionary %@ not found in list of available Nami Language Codes:\n%@", languageString, [NamiLanguageCodes allAvailiableNamiLanguageCodes]);
|
|
52
51
|
}
|
|
53
52
|
}
|
|
54
|
-
|
|
53
|
+
|
|
55
54
|
NSObject *bypassString = configDict[@"bypassStore"];
|
|
56
55
|
if ( bypassString != NULL )
|
|
57
56
|
{
|
|
@@ -66,7 +65,7 @@ RCT_EXPORT_METHOD(configure: (NSDictionary *)configDict) {
|
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
|
-
|
|
68
|
+
|
|
70
69
|
NSObject *developmentModeString = configDict[@"developmentMode"];
|
|
71
70
|
if ( developmentModeString != NULL )
|
|
72
71
|
{
|
|
@@ -81,10 +80,10 @@ RCT_EXPORT_METHOD(configure: (NSDictionary *)configDict) {
|
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
82
|
}
|
|
84
|
-
|
|
83
|
+
|
|
85
84
|
// Start commands with header iformation for Nami to let them know this is a React client.
|
|
86
|
-
NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:2.0.
|
|
87
|
-
|
|
85
|
+
NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:2.0.5"]];
|
|
86
|
+
|
|
88
87
|
// Add additional namiCommands app may have sent in.
|
|
89
88
|
NSObject *appCommandStrings = configDict[@"namiCommands"];
|
|
90
89
|
if ( appCommandStrings != NULL ) {
|
|
@@ -97,10 +96,10 @@ RCT_EXPORT_METHOD(configure: (NSDictionary *)configDict) {
|
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
|
-
|
|
99
|
+
|
|
101
100
|
config.namiCommands = namiCommandStrings;
|
|
102
101
|
|
|
103
|
-
|
|
102
|
+
|
|
104
103
|
[Nami configureWithNamiConfig:config];
|
|
105
104
|
}
|
|
106
105
|
}
|
|
@@ -110,15 +109,15 @@ RCT_EXPORT_METHOD(performNamiCommand: (NSString *)command) {
|
|
|
110
109
|
}
|
|
111
110
|
|
|
112
111
|
RCT_EXPORT_METHOD(setExternalIdentifier: (NSString *)externalIdentifier type:(NSString *)type completion: (RCTResponseSenderBlock) completion) {
|
|
113
|
-
|
|
112
|
+
|
|
114
113
|
NamiExternalIdentifierType useType;
|
|
115
|
-
|
|
114
|
+
|
|
116
115
|
if ( [type isEqualToString:@"sha256"] ) {
|
|
117
116
|
useType = NamiExternalIdentifierTypeSha256;
|
|
118
117
|
} else {
|
|
119
118
|
useType = NamiExternalIdentifierTypeUuid;
|
|
120
119
|
}
|
|
121
|
-
|
|
120
|
+
|
|
122
121
|
NSLog(@"NamiBridge: Setting external identifier %@ of type %@", externalIdentifier, type);
|
|
123
122
|
|
|
124
123
|
[Nami setExternalIdentifierWithExternalIdentifier:externalIdentifier type:useType completion:^(BOOL success, NSError * _Nullable error) {
|
|
@@ -132,7 +131,7 @@ RCT_EXPORT_METHOD(setExternalIdentifier: (NSString *)externalIdentifier type:(N
|
|
|
132
131
|
RCT_EXPORT_METHOD(getExternalIdentifier:(RCTResponseSenderBlock)completion)
|
|
133
132
|
{
|
|
134
133
|
NSString *externalIdentifier = [Nami getExternalIdentifier];
|
|
135
|
-
|
|
134
|
+
|
|
136
135
|
if (externalIdentifier == NULL || [externalIdentifier length] == 0) {
|
|
137
136
|
completion(@[]);
|
|
138
137
|
} else {
|
|
@@ -144,7 +143,8 @@ RCT_EXPORT_METHOD(clearExternalIdentifier:(RCTResponseSenderBlock)completion) {
|
|
|
144
143
|
NSLog(@"NamiBridge: Clearing external identifier.");
|
|
145
144
|
[Nami clearExternalIdentifierWithCompletion:^(BOOL success, NSError * _Nullable error) {
|
|
146
145
|
if (error) {
|
|
147
|
-
|
|
146
|
+
completion(@[error]);
|
|
147
|
+
}
|
|
148
148
|
completion(nil);
|
|
149
149
|
}];
|
|
150
150
|
}
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
self = [super init];
|
|
30
30
|
if (self) {
|
|
31
31
|
hasNamiAanlyticsEmitterListeners = NO;
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
[NamiAnalyticsSupport registerAnalyticsHandlerWithHandler: ^(NamiAnalyticsActionType actionType , NSDictionary<NSString *,id> * _Nonnull anaytlicsDict) {
|
|
34
34
|
[self sendAnalyticsEventForAction:actionType anayticsItems:anaytlicsDict];
|
|
35
35
|
}];
|
package/ios/NamiBridgeUtil.m
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
productDict[@"priceLanguage"] = productInt.priceLocale.languageCode;
|
|
29
29
|
productDict[@"priceCountry"] = productInt.priceLocale.countryCode;
|
|
30
30
|
productDict[@"priceCurrency"] = productInt.priceLocale.currencyCode;
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
// Add smart text processed values for sku buttons to sku dictionary
|
|
33
33
|
productDict[@"displayText"] = [sku namiDisplayText];
|
|
34
34
|
productDict[@"displaySubText"] = [sku namiSubDisplayText];
|
|
@@ -71,18 +71,18 @@
|
|
|
71
71
|
|
|
72
72
|
+ (NSDictionary<NSString *,NSString *> *) purchaseToPurchaseDict:(NamiPurchase *)purchase {
|
|
73
73
|
NSMutableDictionary<NSString *,id> *purchaseDict = [NSMutableDictionary new];
|
|
74
|
-
|
|
74
|
+
|
|
75
75
|
purchaseDict[@"skuIdentifier"] = purchase.skuID;
|
|
76
76
|
purchaseDict[@"transactionIdentifier"] = purchase.transactionIdentifier;
|
|
77
77
|
|
|
78
78
|
// Removed, not sure why, should add back in when possible.
|
|
79
79
|
// purchaseDict[@"purchaseInitiatedTimestamp"] = [self javascriptDateFromNSDate:purchase.purchaseInitiatedTimestamp];
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
NSDate *subscriptionExpirationDate = purchase.expires;
|
|
82
82
|
if (subscriptionExpirationDate != nil) {
|
|
83
83
|
purchaseDict[@"subscriptionExpirationDate"] = [self javascriptDateFromNSDate:subscriptionExpirationDate];
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
NSString *convertedSourceString = @"UNKNOWN";
|
|
87
87
|
switch (purchase.purchaseSource) {
|
|
88
88
|
case 0:
|
|
@@ -98,9 +98,9 @@
|
|
|
98
98
|
break;
|
|
99
99
|
}
|
|
100
100
|
purchaseDict[@"purchaseSource"] = convertedSourceString;
|
|
101
|
-
|
|
101
|
+
|
|
102
102
|
// NamiSKU *purchaseSku = [purchase ]
|
|
103
|
-
|
|
103
|
+
|
|
104
104
|
return purchaseDict;
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
+ (NSArray *)stripPresentationPositionFromOrderedMetadataForPaywallMetaDict: (NSDictionary *)paywallMeta {
|
|
110
110
|
NSArray *baseSkuArray = [paywallMeta objectForKey:@"sku_ordered_metadata"];
|
|
111
111
|
NSMutableArray *newOrderedMetadata = [NSMutableArray new];
|
|
112
|
-
|
|
112
|
+
|
|
113
113
|
if ( [baseSkuArray isKindOfClass:[NSArray class]] ) {
|
|
114
114
|
for (NSDictionary *baseSkuDict in baseSkuArray) {
|
|
115
115
|
NSMutableDictionary *skuFormattingDict = [NSMutableDictionary dictionaryWithDictionary:baseSkuDict];
|
|
@@ -127,12 +127,12 @@
|
|
|
127
127
|
entitlementDict[@"namiID"] = [entitlement namiID] ? [entitlement namiID] : @"";
|
|
128
128
|
entitlementDict[@"desc"] = [entitlement desc] ? [entitlement desc] : @"";
|
|
129
129
|
entitlementDict[@"name"] = [entitlement name] ? [entitlement name] : @"";
|
|
130
|
-
|
|
130
|
+
|
|
131
131
|
if (entitlementDict[@"referenceID"] == nil || [[entitlement referenceID] length] == 0) {
|
|
132
132
|
NSLog(@"NamiBridge: Bad entitlement in system, empty referenceID.");
|
|
133
133
|
return nil;
|
|
134
134
|
}
|
|
135
|
-
|
|
135
|
+
|
|
136
136
|
NSArray <NamiPurchase *>*activePurchases = [entitlement activePurchases];
|
|
137
137
|
NSMutableArray *convertedActivePurchases = [NSMutableArray array];
|
|
138
138
|
for (NamiPurchase *purchase in activePurchases) {
|
|
@@ -142,7 +142,7 @@
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
entitlementDict[@"activePurchases"] = convertedActivePurchases;
|
|
145
|
-
|
|
145
|
+
|
|
146
146
|
NSArray <NamiSKU *>*purchasedSKUs = [entitlement purchasedSKUs];
|
|
147
147
|
NSMutableArray *convertedPurchasedSKUs = [NSMutableArray array];
|
|
148
148
|
for (NamiSKU *sku in purchasedSKUs) {
|
|
@@ -152,8 +152,8 @@
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
entitlementDict[@"purchasedSKUs"] = convertedPurchasedSKUs;
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
|
|
156
|
+
|
|
157
157
|
NSArray <NamiSKU *>*relatedSKUs = [entitlement relatedSKUs];
|
|
158
158
|
NSMutableArray *convertedRelatedSKUs = [NSMutableArray array];
|
|
159
159
|
for (NamiSKU *sku in relatedSKUs) {
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
entitlementDict[@"relatedSKUs"] = convertedRelatedSKUs;
|
|
166
|
-
|
|
166
|
+
|
|
167
167
|
NamiPurchase *lastPurchase;
|
|
168
168
|
for (NamiPurchase *purchase in [entitlement activePurchases]) {
|
|
169
169
|
if (lastPurchase == NULL || ([lastPurchase purchaseInitiatedTimestamp] < [purchase purchaseInitiatedTimestamp])) {
|
|
@@ -173,9 +173,9 @@
|
|
|
173
173
|
if (lastPurchase != NULL) {
|
|
174
174
|
// entitlementDict[@"latestPurchase"] = [NamiBridgeUtil purchaseToPurchaseDict:lastPurchase];
|
|
175
175
|
}
|
|
176
|
-
|
|
176
|
+
|
|
177
177
|
NSString *lastPurchaseSKUID = [lastPurchase skuID];
|
|
178
|
-
|
|
178
|
+
|
|
179
179
|
NamiSKU *lastPurchasedSKU;
|
|
180
180
|
if (lastPurchaseSKUID != NULL ) {
|
|
181
181
|
for (NamiSKU *sku in [entitlement purchasedSKUs]) {
|
|
@@ -184,7 +184,7 @@
|
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
|
|
187
|
+
|
|
188
188
|
if (lastPurchasedSKU != NULL) {
|
|
189
189
|
lastPurchasedSKU = [[entitlement purchasedSKUs] lastObject];
|
|
190
190
|
}
|
|
@@ -192,7 +192,7 @@
|
|
|
192
192
|
if (lastPurchasedSKU != NULL) {
|
|
193
193
|
// entitlementDict[@"lastPurchasedSKU"] = [NamiBridgeUtil skuToSKUDict:lastPurchasedSKU];
|
|
194
194
|
}
|
|
195
|
-
|
|
195
|
+
|
|
196
196
|
return entitlementDict;
|
|
197
197
|
}
|
|
198
198
|
|
|
@@ -201,23 +201,23 @@
|
|
|
201
201
|
+ (NSString *)javascriptDateFromNSDate:(NSDate *)purchaseTimestamp {
|
|
202
202
|
NSTimeZone *UTC = [NSTimeZone timeZoneWithAbbreviation: @"UTC"];
|
|
203
203
|
NSISO8601DateFormatOptions options = NSISO8601DateFormatWithInternetDateTime | NSISO8601DateFormatWithDashSeparatorInDate | NSISO8601DateFormatWithColonSeparatorInTime | NSISO8601DateFormatWithTimeZone;
|
|
204
|
-
|
|
204
|
+
|
|
205
205
|
return [NSISO8601DateFormatter stringFromDate:purchaseTimestamp timeZone:UTC formatOptions:options];
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
|
|
209
209
|
+ (NSDictionary<NSString *,NSString *> *) customerJourneyStateDict {
|
|
210
210
|
CustomerJourneyState *journeyState = [NamiCustomerManager currentCustomerJourneyState];
|
|
211
|
-
|
|
211
|
+
|
|
212
212
|
BOOL formerSubscriber = [journeyState formerSubscriber];
|
|
213
213
|
BOOL inGracePeriod = [journeyState inGracePeriod];
|
|
214
214
|
BOOL inTrialPeriod = [journeyState inTrialPeriod];
|
|
215
215
|
BOOL inIntroOfferPeriod = [journeyState inIntroOfferPeriod];
|
|
216
|
-
|
|
216
|
+
|
|
217
217
|
BOOL isCancelled = [journeyState isCancelled];
|
|
218
218
|
BOOL inPause = [journeyState inPause];
|
|
219
219
|
BOOL inAccountHold = [journeyState inAccountHold];
|
|
220
|
-
|
|
220
|
+
|
|
221
221
|
NSDictionary *journeyDict = @{@"formerSubscriber":@(formerSubscriber),
|
|
222
222
|
@"inGracePeriod":@(inGracePeriod),
|
|
223
223
|
@"inTrialPeriod":@(inTrialPeriod),
|
|
@@ -231,52 +231,52 @@
|
|
|
231
231
|
|
|
232
232
|
+ (NSDictionary<NSString *,NSString *> *) paywallStylingToPaywallStylingDict:(PaywallStyleData *)styling {
|
|
233
233
|
NSMutableDictionary<NSString *,id> *stylingDict = [NSMutableDictionary new];
|
|
234
|
-
if (styling != nil) {
|
|
234
|
+
if (styling != nil) {
|
|
235
235
|
stylingDict[@"backgroundColor"] = [NamiBridgeUtil hexStringForColor: styling.backgroundColor];
|
|
236
|
-
|
|
236
|
+
|
|
237
237
|
stylingDict[@"bodyFontSize"] = @(styling.bodyFontSize);
|
|
238
238
|
stylingDict[@"bodyTextColor"] = [NamiBridgeUtil hexStringForColor: styling.bodyTextColor];
|
|
239
239
|
stylingDict[@"bodyShadowColor"] = [NamiBridgeUtil hexStringForColor: styling.bodyShadowColor];
|
|
240
240
|
stylingDict[@"bodyShadowRadius"] = @(styling.bodyShadowRadius);
|
|
241
|
-
|
|
241
|
+
|
|
242
242
|
stylingDict[@"titleFontSize"] = @(styling.titleFontSize);
|
|
243
243
|
stylingDict[@"titleTextColor"] = [NamiBridgeUtil hexStringForColor: styling.titleTextColor];
|
|
244
244
|
stylingDict[@"titleShadowColor"] = [NamiBridgeUtil hexStringForColor: styling.titleShadowColor];
|
|
245
245
|
stylingDict[@"titleShadowRadius"] = @(styling.titleShadowRadius);
|
|
246
|
-
|
|
246
|
+
|
|
247
247
|
stylingDict[@"closeButtonFontSize"] = @(styling.closeButtonFontSize);
|
|
248
248
|
stylingDict[@"closeButtonTextColor"] = [NamiBridgeUtil hexStringForColor: styling.closeButtonTextColor];
|
|
249
249
|
stylingDict[@"closeButtonShadowColor"] = [NamiBridgeUtil hexStringForColor: styling.closeButtonShadowColor];
|
|
250
250
|
stylingDict[@"closeButtonShadowRadius"] = @(styling.closeButtonShadowRadius);
|
|
251
|
-
|
|
251
|
+
|
|
252
252
|
stylingDict[@"bottomOverlayColor"] = [NamiBridgeUtil hexStringForColor: styling.bottomOverlayColor];
|
|
253
253
|
stylingDict[@"bottomOverlayCornerRadius"] = @(styling.bottomOverlayCornerRadius);
|
|
254
|
-
|
|
254
|
+
|
|
255
255
|
stylingDict[@"skuButtonColor"] = [NamiBridgeUtil hexStringForColor: styling.skuButtonColor];
|
|
256
256
|
stylingDict[@"skuButtonTextColor"] = [NamiBridgeUtil hexStringForColor: styling.skuButtonTextColor];
|
|
257
|
-
|
|
257
|
+
|
|
258
258
|
stylingDict[@"featuredSkusButtonColor"] = [NamiBridgeUtil hexStringForColor: styling.featuredSkusButtonColor];
|
|
259
259
|
stylingDict[@"featuredSkusButtonTextColor"] = [NamiBridgeUtil hexStringForColor: styling.featuredSkusButtonTextColor];
|
|
260
|
-
|
|
260
|
+
|
|
261
261
|
stylingDict[@"signinButtonFontSize"] = @(styling.signinButtonFontSize);
|
|
262
262
|
stylingDict[@"signinButtonTextColor"] = [NamiBridgeUtil hexStringForColor: styling.signinButtonTextColor];
|
|
263
263
|
stylingDict[@"signinButtonShadowColor"] = [NamiBridgeUtil hexStringForColor: styling.signinButtonShadowColor];
|
|
264
264
|
stylingDict[@"signinButtonShadowRadius"] = @(styling.signinButtonShadowRadius);
|
|
265
|
-
|
|
265
|
+
|
|
266
266
|
stylingDict[@"restoreButtonFontSize"] = @(styling.restoreButtonFontSize);
|
|
267
267
|
stylingDict[@"restoreButtonTextColor"] = [NamiBridgeUtil hexStringForColor: styling.restoreButtonTextColor];
|
|
268
268
|
stylingDict[@"restoreButtonShadowColor"] = [NamiBridgeUtil hexStringForColor: styling.restoreButtonShadowColor];
|
|
269
269
|
stylingDict[@"restoreButtonShadowRadius"] = @(styling.restoreButtonShadowRadius);
|
|
270
|
-
|
|
270
|
+
|
|
271
271
|
stylingDict[@"purchaseTermsFontSize"] = @(styling.purchaseTermsFontSize);
|
|
272
272
|
stylingDict[@"purchaseTermsTextColor"] = [NamiBridgeUtil hexStringForColor: styling.purchaseTermsTextColor];
|
|
273
273
|
stylingDict[@"purchaseTermsShadowColor"] = [NamiBridgeUtil hexStringForColor: styling.purchaseTermsShadowColor];
|
|
274
274
|
stylingDict[@"purchaseTermsShadowRadius"] = @(styling.purchaseTermsShadowRadius);
|
|
275
|
-
|
|
275
|
+
|
|
276
276
|
|
|
277
277
|
stylingDict[@"termsLinkColor"] = styling.termsLinkColor;
|
|
278
278
|
}
|
|
279
|
-
|
|
279
|
+
|
|
280
280
|
return stylingDict;
|
|
281
281
|
}
|
|
282
282
|
|
package/ios/NamiEmitter.m
CHANGED
|
@@ -32,37 +32,37 @@ static NamiEmitter *namiEmitter;
|
|
|
32
32
|
self = [super init];
|
|
33
33
|
if (self) {
|
|
34
34
|
hasNamiEmitterListeners = NO;
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
// Tell Nami to listen for purchases and we'll forward them on to listeners
|
|
37
37
|
[NamiPurchaseManager registerPurchasesChangedHandler:^(NSArray<NamiPurchase *> * _Nonnull purchases, enum NamiPurchaseState purchaseState, NSError * _Nullable error) {
|
|
38
38
|
[self sendEventPurchaseMadeWithPurchases:purchases withState:purchaseState error:error];
|
|
39
39
|
}];
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
[NamiEntitlementManager registerEntitlementsChangedHandler:^(NSArray<NamiEntitlement *> * _Nonnull entitlements) {
|
|
42
42
|
[self sendEventEntitlementsChangedWithEntitlements:entitlements];
|
|
43
43
|
}];
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
|
|
45
|
+
|
|
46
46
|
[NamiPaywallManager registerSignInHandler:^(UIViewController * _Nullable fromVC, NSString * _Nonnull developerPaywallID, NamiPaywall * _Nonnull paywallMetadata) {
|
|
47
47
|
[self sendSignInActivateFromVC:fromVC forPaywall:developerPaywallID paywallMetadata:paywallMetadata];
|
|
48
48
|
}];
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
[NamiPaywallManager registerPaywallRaiseHandler:^(UIViewController * _Nullable fromVC, NSArray<NamiSKU *> * _Nullable products, NSString * _Nonnull developerPaywallID, NamiPaywall * _Nonnull paywallMetadata) {
|
|
51
51
|
[self sendPaywallActivatedFromVC:fromVC forPaywall:developerPaywallID withProducts:products paywallMetadata:paywallMetadata];
|
|
52
52
|
}];
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
[NamiPaywallManager registerBlockingPaywallClosedHandler:^{
|
|
55
55
|
[self sendBlockingPaywallClosed];
|
|
56
56
|
}];
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
[NamiPurchaseManager registerRestorePurchasesHandlerWithRestorePurchasesStateHandler:^(enum NamiRestorePurchasesState state, NSArray<NamiPurchase *> * _Nonnull newPurchases, NSArray<NamiPurchase *> * _Nonnull oldPurchases, NSError * _Nullable error) {
|
|
59
59
|
[self sendRestorePurchasesStateChanged:state newPurchases:newPurchases oldPurchases:oldPurchases error:error];
|
|
60
60
|
}];
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
[NamiCustomerManager registerJourneyStateChangedHandler:^(CustomerJourneyState * _Nonnull journeyState) {
|
|
63
63
|
[self sendEventCustomerJourneyStateChanged:journeyState];
|
|
64
64
|
}];
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
}
|
|
67
67
|
namiEmitter = self;
|
|
68
68
|
return self;
|
|
@@ -88,7 +88,7 @@ static NamiEmitter *namiEmitter;
|
|
|
88
88
|
for (NamiPurchase *purchase in purchases) {
|
|
89
89
|
[productIDs addObject:purchase.skuID];
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
|
|
92
92
|
return productIDs;
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -118,7 +118,7 @@ bool hasNamiEmitterListeners;
|
|
|
118
118
|
|
|
119
119
|
-(NSString *)purchaseStateToString:(NamiPurchaseState)purchaseState {
|
|
120
120
|
switch (purchaseState) {
|
|
121
|
-
|
|
121
|
+
|
|
122
122
|
case NamiPurchaseStatePending:
|
|
123
123
|
return @"PENDING";
|
|
124
124
|
break;
|
|
@@ -133,7 +133,7 @@ bool hasNamiEmitterListeners;
|
|
|
133
133
|
break;
|
|
134
134
|
case NamiPurchaseStateUnsubscribed:
|
|
135
135
|
return @"UNSUBSCRIBED";
|
|
136
|
-
break;
|
|
136
|
+
break;
|
|
137
137
|
case NamiPurchaseStateDeferred:
|
|
138
138
|
return @"DEFERRED";
|
|
139
139
|
break;
|
|
@@ -142,7 +142,7 @@ bool hasNamiEmitterListeners;
|
|
|
142
142
|
break;
|
|
143
143
|
case NamiPurchaseStateCancelled:
|
|
144
144
|
return @"CANCELLED";
|
|
145
|
-
break;
|
|
145
|
+
break;
|
|
146
146
|
case NamiPurchaseStateUnknown:
|
|
147
147
|
return @"UNKNOWN";
|
|
148
148
|
break;
|
|
@@ -154,7 +154,7 @@ bool hasNamiEmitterListeners;
|
|
|
154
154
|
|
|
155
155
|
- (void)sendEventEntitlementsChangedWithEntitlements:(NSArray<NamiEntitlement *>*)entitlements {
|
|
156
156
|
if (hasNamiEmitterListeners) {
|
|
157
|
-
|
|
157
|
+
|
|
158
158
|
NSMutableArray *convertedEntitlementDicts = [NSMutableArray new];
|
|
159
159
|
for ( NamiEntitlement *entitlementRecord in entitlements ) {
|
|
160
160
|
if ( entitlementRecord.referenceID != nil ) {
|
|
@@ -162,25 +162,25 @@ bool hasNamiEmitterListeners;
|
|
|
162
162
|
[convertedEntitlementDicts addObject:entitlementDict];
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
|
|
165
|
+
|
|
166
166
|
NSMutableDictionary *sendDict = [NSMutableDictionary dictionary];
|
|
167
167
|
sendDict[@"activeEntitlements"] = convertedEntitlementDicts;
|
|
168
|
-
|
|
168
|
+
|
|
169
169
|
[self sendEventWithName:@"EntitlementsChanged" body:sendDict];
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
- (void)sendEventPreparePaywallForDisplayFinishedWithResult:(BOOL)success developerPaywallID: (NSString * _Nullable) developerPaywallID error:(NSError * _Nullable) error {
|
|
174
174
|
if (hasNamiEmitterListeners) {
|
|
175
|
-
|
|
175
|
+
|
|
176
176
|
NSMutableDictionary *sendDict = [NSMutableDictionary dictionaryWithDictionary: @{ @"success": @(success) }];
|
|
177
|
-
|
|
177
|
+
|
|
178
178
|
if (developerPaywallID != nil) {
|
|
179
179
|
[sendDict addEntriesFromDictionary:@{
|
|
180
180
|
@"developerPaywallID": developerPaywallID
|
|
181
181
|
}];
|
|
182
182
|
}
|
|
183
|
-
|
|
183
|
+
|
|
184
184
|
if (error != nil) {
|
|
185
185
|
[sendDict addEntriesFromDictionary:@{
|
|
186
186
|
@"errorCode": @(error.code),
|
|
@@ -188,7 +188,7 @@ bool hasNamiEmitterListeners;
|
|
|
188
188
|
}
|
|
189
189
|
];
|
|
190
190
|
}
|
|
191
|
-
|
|
191
|
+
|
|
192
192
|
NSLog(@"NamiBridge: Info: attempting to send result of preparePaywallForDisplay with result dictionary: %@", sendDict);
|
|
193
193
|
[self sendEventWithName:@"PreparePaywallFinished" body:sendDict];
|
|
194
194
|
}
|
|
@@ -203,10 +203,10 @@ bool hasNamiEmitterListeners;
|
|
|
203
203
|
|
|
204
204
|
- (void)sendEventPurchaseMadeWithPurchases:(NSArray<NamiPurchase *>*)purchases withState:(NamiPurchaseState)purchaseState error:(NSError *)error {
|
|
205
205
|
if (hasNamiEmitterListeners) {
|
|
206
|
-
|
|
207
|
-
|
|
206
|
+
|
|
207
|
+
|
|
208
208
|
NSString *convertedState = [self purchaseStateToString:purchaseState];
|
|
209
|
-
|
|
209
|
+
|
|
210
210
|
NSMutableArray *convertedPurchaseDicts = [NSMutableArray new];
|
|
211
211
|
for ( NamiPurchase *purchaseRecord in purchases ) {
|
|
212
212
|
if ( purchaseRecord.skuID != nil ) {
|
|
@@ -214,16 +214,16 @@ bool hasNamiEmitterListeners;
|
|
|
214
214
|
[convertedPurchaseDicts addObject:purchaseDict];
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
|
|
217
|
+
|
|
218
218
|
NSString *localizedErrorDescription = [error localizedDescription];
|
|
219
|
-
|
|
219
|
+
|
|
220
220
|
NSMutableDictionary *sendDict = [NSMutableDictionary dictionary];
|
|
221
221
|
sendDict[@"purchases"] = convertedPurchaseDicts;
|
|
222
222
|
sendDict[@"purchaseState"] = convertedState;
|
|
223
223
|
if (localizedErrorDescription != nil) {
|
|
224
224
|
sendDict[@"error"] = localizedErrorDescription;
|
|
225
225
|
}
|
|
226
|
-
|
|
226
|
+
|
|
227
227
|
[self sendEventWithName:@"PurchasesChanged" body:sendDict];
|
|
228
228
|
}
|
|
229
229
|
}
|
|
@@ -247,7 +247,7 @@ bool hasNamiEmitterListeners;
|
|
|
247
247
|
for (NamiSKU *sku in products) {
|
|
248
248
|
[skuDicts addObject:[NamiBridgeUtil skuToSKUDict:sku]];
|
|
249
249
|
}
|
|
250
|
-
|
|
250
|
+
|
|
251
251
|
NSMutableDictionary *paywallMeta = [NSMutableDictionary dictionaryWithDictionary:paywallMetadata.namiPaywallInfoDict];
|
|
252
252
|
// This part is really meant to be internally facing, scrub from dictionary
|
|
253
253
|
|
|
@@ -258,7 +258,7 @@ bool hasNamiEmitterListeners;
|
|
|
258
258
|
marketingContentDictionary[@"title"] = [paywallMetadata title];
|
|
259
259
|
paywallMeta[@"marketing_content"] = marketingContentDictionary;
|
|
260
260
|
paywallMeta[@"purchase_terms"] = [paywallMetadata purchaseTerms];
|
|
261
|
-
|
|
261
|
+
|
|
262
262
|
// Strip out presention_position from all listed sku items
|
|
263
263
|
NSArray *cleanedOrderdMetadata = [NamiBridgeUtil stripPresentationPositionFromOrderedMetadataForPaywallMetaDict:paywallMeta];
|
|
264
264
|
[paywallMeta setObject:cleanedOrderdMetadata forKey:@"formatted_skus"];
|
|
@@ -268,8 +268,8 @@ bool hasNamiEmitterListeners;
|
|
|
268
268
|
|
|
269
269
|
NSDictionary *paywallStylingDict = [NamiBridgeUtil paywallStylingToPaywallStylingDict:[paywallMetadata styleData]];
|
|
270
270
|
paywallMeta[@"styleData"] = paywallStylingDict;
|
|
271
|
-
|
|
272
|
-
// remove keys that are inconsistent with android
|
|
271
|
+
|
|
272
|
+
// remove keys that are inconsistent with android
|
|
273
273
|
[paywallMeta removeObjectForKey:@"body"];
|
|
274
274
|
[paywallMeta removeObjectForKey:@"title"];
|
|
275
275
|
[paywallMeta removeObjectForKey:@"style"];
|
|
@@ -291,10 +291,10 @@ bool hasNamiEmitterListeners;
|
|
|
291
291
|
} else {
|
|
292
292
|
initialDict = @{@"state": [NSNumber numberWithBool:state], @"stateDesc": [self restorePurchaseStateDescriptionFromCode:state]};
|
|
293
293
|
}
|
|
294
|
-
|
|
294
|
+
|
|
295
295
|
NSMutableDictionary *retDict = [NSMutableDictionary dictionary];
|
|
296
296
|
[retDict addEntriesFromDictionary:initialDict];
|
|
297
|
-
|
|
297
|
+
|
|
298
298
|
NSMutableArray *newPurchaseDicts = [NSMutableArray array];
|
|
299
299
|
for ( NamiPurchase *purchaseRecord in newPurchases ) {
|
|
300
300
|
if ( purchaseRecord.skuID == nil ) {
|
|
@@ -310,10 +310,10 @@ bool hasNamiEmitterListeners;
|
|
|
310
310
|
NSDictionary *purchaseDict = [NamiBridgeUtil purchaseToPurchaseDict:purchaseRecord];
|
|
311
311
|
[oldPurchaseDicts addObject:purchaseDict];
|
|
312
312
|
}
|
|
313
|
-
|
|
313
|
+
|
|
314
314
|
retDict[@"newPurchases"] = newPurchaseDicts;
|
|
315
315
|
retDict[@"oldPurchases"] = oldPurchaseDicts;
|
|
316
|
-
|
|
316
|
+
|
|
317
317
|
NSLog(@"NamiBridge: Info: RestorePurchases state change: %@", retDict);
|
|
318
318
|
|
|
319
319
|
return retDict;
|
|
@@ -345,14 +345,14 @@ bool hasNamiEmitterListeners;
|
|
|
345
345
|
// Let system know a blocking paywall has been closed, in case they want to react specifically.
|
|
346
346
|
if (hasNamiEmitterListeners) {
|
|
347
347
|
NSMutableDictionary *paywallMeta = [NSMutableDictionary dictionary];
|
|
348
|
-
|
|
348
|
+
|
|
349
349
|
// Strip out presention_position from all listed sku items
|
|
350
350
|
NSArray *cleanedOrderdMetadata = [NamiBridgeUtil stripPresentationPositionFromOrderedMetadataForPaywallMetaDict:paywallMeta];
|
|
351
351
|
[paywallMeta setObject:cleanedOrderdMetadata forKey:@"formatted_skus"];
|
|
352
|
-
|
|
352
|
+
|
|
353
353
|
[paywallMeta removeObjectForKey:@"sku_ordered_metadata"];
|
|
354
354
|
[paywallMeta removeObjectForKey:@"skus"];
|
|
355
|
-
|
|
355
|
+
|
|
356
356
|
[self sendEventWithName:@"BlockingPaywallClosed" body:@{ @"blockingPaywallClosed": @true }];
|
|
357
357
|
}
|
|
358
358
|
}
|
|
@@ -34,16 +34,16 @@ RCT_EXPORT_METHOD(isEntitlementActive:(nonnull NSString*)entitlementRefID comple
|
|
|
34
34
|
RCT_EXPORT_METHOD(getEntitlements:(RCTResponseSenderBlock)completion)
|
|
35
35
|
{
|
|
36
36
|
NSArray<NamiEntitlement *> *entitlements = [NamiEntitlementManager getEntitlements];
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
NSMutableArray *entitlementDicts = [NSMutableArray new];
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
for (NamiEntitlement *entitlement in entitlements) {
|
|
41
41
|
NSDictionary *entitlementDict = [NamiBridgeUtil entitlementToEntitlementDict:entitlement];
|
|
42
42
|
if ([entitlementDict count] > 0) {
|
|
43
43
|
[entitlementDicts addObject:entitlementDict];
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
completion(@[entitlementDicts]);
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -51,16 +51,16 @@ RCT_EXPORT_METHOD(getEntitlements:(RCTResponseSenderBlock)completion)
|
|
|
51
51
|
RCT_EXPORT_METHOD(activeEntitlements:(RCTResponseSenderBlock)completion)
|
|
52
52
|
{
|
|
53
53
|
NSArray<NamiEntitlement *> *entitlements = [NamiEntitlementManager activeEntitlements];
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
NSMutableArray *entitlementDicts = [NSMutableArray new];
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
for (NamiEntitlement *entitlement in entitlements) {
|
|
58
58
|
NSDictionary *entitlementDict = [NamiBridgeUtil entitlementToEntitlementDict:entitlement];
|
|
59
59
|
if ([entitlementDict count] > 0) {
|
|
60
60
|
[entitlementDicts addObject:entitlementDict];
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
completion(@[entitlementDicts]);
|
|
65
65
|
}
|
|
66
66
|
|
|
@@ -77,9 +77,9 @@ RCT_EXPORT_METHOD(setEntitlements:(NSArray *)entitlementSetterDicts)
|
|
|
77
77
|
NSString *expiresStr = entitlementSetterDict[@"expires"];
|
|
78
78
|
// TODO: figure out reverse parsing of date string passed in
|
|
79
79
|
NSDate* expires = NULL;
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
NSString *platormStr = entitlementSetterDict[@"platform"];
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
NamiPlatformType platform = NamiPlatformTypeOther;
|
|
84
84
|
if ([platormStr isEqualToString:@"android"]) {
|
|
85
85
|
platform = NamiPlatformTypeAndroid;
|
|
@@ -90,16 +90,16 @@ RCT_EXPORT_METHOD(setEntitlements:(NSArray *)entitlementSetterDicts)
|
|
|
90
90
|
} else if ([platormStr isEqualToString:@"web"]) {
|
|
91
91
|
platform = NamiPlatformTypeWeb;
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
|
|
94
94
|
NamiEntitlementSetter *setter = [NamiEntitlementSetter alloc];
|
|
95
95
|
setter = [setter initWithId:referenceID platform:platform purchasedSKUid:purchasedSKUid expires:expires];
|
|
96
|
-
|
|
96
|
+
|
|
97
97
|
[entitlementSetters addObject:setter];
|
|
98
98
|
} else {
|
|
99
99
|
NSLog(@"Warning, entitlement to set had empty referenceID, whole entitlement is \n %@", entitlementSetterDict);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
|
|
103
103
|
[NamiEntitlementManager setEntitlements:entitlementSetters];
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -83,18 +83,18 @@ RCT_EXPORT_METHOD(fetchCustomPaywallMetaForDeveloperID:(NSString *)developerPayw
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
NSMutableDictionary *paywallMeta = [NSMutableDictionary dictionaryWithDictionary:paywallMetadata.namiPaywallInfoDict];
|
|
86
|
-
// This part is really meant to be internally facing, scrub from dictionary
|
|
86
|
+
// This part is really meant to be internally facing, scrub from dictionary
|
|
87
87
|
// Strip out presention_position from all listed sku items
|
|
88
|
-
NSArray *cleanedOrderdMetadata = [NamiBridgeUtil stripPresentationPositionFromOrderedMetadataForPaywallMetaDict:paywallMeta];
|
|
88
|
+
NSArray *cleanedOrderdMetadata = [NamiBridgeUtil stripPresentationPositionFromOrderedMetadataForPaywallMetaDict:paywallMeta];
|
|
89
89
|
[paywallMeta setObject:cleanedOrderdMetadata forKey:@"formatted_skus"];
|
|
90
|
-
|
|
90
|
+
|
|
91
91
|
[paywallMeta removeObjectForKey:@"sku_ordered_metadata"];
|
|
92
92
|
[paywallMeta removeObjectForKey:@"skus"];
|
|
93
93
|
|
|
94
94
|
NSDictionary *paywallStylingDict = [NamiBridgeUtil paywallStylingToPaywallStylingDict:[paywallMetadata styleData]];
|
|
95
95
|
paywallMeta[@"styleData"] = paywallStylingDict;
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
|
|
97
|
+
|
|
98
98
|
NSArray *wrapperArray = @[@{ @"namiSkus": productDicts,
|
|
99
99
|
@"developerPaywallID": developerPaywallID,
|
|
100
100
|
@"paywallMetadata": paywallMeta }];
|
|
@@ -47,9 +47,9 @@ RCT_EXPORT_METHOD(purchases:(RCTResponseSenderBlock)completion)
|
|
|
47
47
|
anyProductNil = YES;
|
|
48
48
|
}
|
|
49
49
|
NSDictionary *purchaseDict = [NamiBridgeUtil purchaseToPurchaseDict:purchaseRecord];
|
|
50
|
-
[convertedPurchaseDicts addObject:purchaseDict];
|
|
50
|
+
[convertedPurchaseDicts addObject:purchaseDict];
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
completion(@[convertedPurchaseDicts]);
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -62,7 +62,7 @@ RCT_EXPORT_METHOD(isSKUIDPurchased:(nonnull NSString*)skuID completion:(RCTRespo
|
|
|
62
62
|
RCT_EXPORT_METHOD(restorePurchasesWithCompletionHandler:(RCTResponseSenderBlock)completion)
|
|
63
63
|
{
|
|
64
64
|
NSLog(@"NamiBridge: Info: Calling RestorePurchasesWithCompletionHandler");
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
[NamiPurchaseManager restorePurchasesWithStatehandler:^(enum NamiRestorePurchasesState state, NSArray<NamiPurchase *> * _Nonnull newPurchases, NSArray<NamiPurchase *> * _Nonnull oldPurchases, NSError * _Nullable error) {
|
|
67
67
|
NSDictionary *retDict = [[NamiEmitter reactInstance] buildRestorePurchasesStateChangedDict:state newPurchases:newPurchases oldPurchases:oldPurchases error:error];
|
|
68
68
|
completion(@[retDict]);
|
|
@@ -72,7 +72,7 @@ RCT_EXPORT_METHOD(restorePurchasesWithCompletionHandler:(RCTResponseSenderBlock)
|
|
|
72
72
|
RCT_EXPORT_METHOD(restorePurchases)
|
|
73
73
|
{
|
|
74
74
|
NSLog(@"NamiBridge: Info: Calling RestorePurchases");
|
|
75
|
-
|
|
75
|
+
|
|
76
76
|
[NamiPurchaseManager restorePurchasesWithStatehandler:^(enum NamiRestorePurchasesState state, NSArray<NamiPurchase *> * _Nonnull newPurchases, NSArray<NamiPurchase *> * _Nonnull oldPurchases, NSError * _Nullable error) {
|
|
77
77
|
[[NamiEmitter reactInstance] sendRestorePurchasesStateChanged:state newPurchases:newPurchases oldPurchases:oldPurchases error:error];
|
|
78
78
|
}];
|
|
@@ -127,7 +127,7 @@ RCT_EXPORT_METHOD(canPresentCodeRedemptionSheet:(RCTResponseSenderBlock)completi
|
|
|
127
127
|
NSLog(@"NamiBridge: Info: Purchase result is %@, purchased is %d, purchaseState is %@, error is %@", purchase, (purchaseState == NamiPurchaseStatePurchased), [NSNumber numberWithInt:(int)purchaseState], [error localizedDescription]);
|
|
128
128
|
if (purchaseState == NamiPurchaseStatePurchased) {
|
|
129
129
|
completion(@[[NSNumber numberWithBool:true]]);
|
|
130
|
-
}
|
|
130
|
+
}
|
|
131
131
|
}];
|
|
132
132
|
} else {
|
|
133
133
|
completion(@[[NSNumber numberWithBool:false]]);
|
package/ios/RNNami.h
CHANGED
package/package.json
CHANGED