react-native-nami-sdk 3.0.9 → 3.0.11
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/.eslintignore +2 -0
- package/.eslintrc.js +12 -0
- package/.github/workflows/CI.yaml +610 -0
- package/.github/workflows/app_prod.yaml +316 -0
- package/.github/workflows/app_stg.yaml +115 -2
- package/.pre-commit-config.yaml +0 -1
- package/android/build.gradle +4 -4
- package/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt +5 -18
- package/android/src/main/java/com/nami/reactlibrary/NamiBridgePackage.java +0 -1
- package/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt +45 -27
- package/android/src/main/java/com/nami/reactlibrary/NamiCustomerManagerBridge.kt +26 -20
- package/android/src/main/java/com/nami/reactlibrary/NamiEntitlementManagerBridgeModule.kt +15 -12
- package/android/src/main/java/com/nami/reactlibrary/NamiMLManagerBridgeModule.kt +8 -0
- package/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt +142 -95
- package/android/src/main/java/com/nami/reactlibrary/NamiPurchaseManagerBridge.kt +12 -14
- package/android/src/main/java/com/nami/reactlibrary/NamiUtil.kt +3 -47
- package/ios/Nami.m +3 -25
- package/ios/NamiCampaignManagerBridge.swift +13 -7
- package/ios/NamiCustomerManager.swift +26 -7
- package/ios/NamiEntitlementManagerBridge.swift +9 -1
- package/ios/NamiMLManagerBridge.m +0 -2
- package/ios/NamiPaywallManagerBridge.m +2 -59
- package/ios/NamiPaywallManagerBridge.swift +67 -58
- package/ios/NamiPurchaseManagerBridge.m +2 -98
- package/ios/NamiPurchaseManagerBridge.swift +45 -5
- package/ios/RNNami-Bridging-Header.h +0 -1
- package/ios/RNNami.xcodeproj/project.pbxproj +1 -62
- package/ios/RNNami.xcworkspace/contents.xcworkspacedata +0 -3
- package/package.json +15 -4
- package/react-native-nami-sdk.podspec +4 -2
- package/src/Nami.d.ts +0 -1
- package/src/NamiCustomerManager.js +2 -2
- package/src/NamiMLManager.d.ts +3 -3
- package/src/NamiMLManager.js +1 -1
- package/src/NamiPaywallManager.d.ts +11 -30
- package/src/NamiPaywallManager.js +13 -8
- package/src/NamiPurchaseManager.d.ts +7 -3
- package/src/types.ts +10 -3
- package/android/src/main/java/com/nami/reactlibrary/NamiEmitter.kt +0 -163
- package/ios/NamiBridgeUtil.h +0 -32
- package/ios/NamiBridgeUtil.m +0 -231
- package/ios/NamiEmitter.m +0 -350
- package/ios/Podfile +0 -71
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
package com.nami.reactlibrary
|
|
2
|
-
|
|
3
|
-
import android.util.Log
|
|
4
|
-
import com.facebook.react.bridge.Arguments
|
|
5
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
7
|
-
import com.facebook.react.bridge.WritableArray
|
|
8
|
-
import com.facebook.react.bridge.WritableMap
|
|
9
|
-
import com.facebook.react.bridge.WritableNativeArray
|
|
10
|
-
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
11
|
-
import com.namiml.billing.NamiPurchase
|
|
12
|
-
import com.namiml.billing.NamiPurchaseManager
|
|
13
|
-
import com.namiml.billing.NamiPurchaseState
|
|
14
|
-
import com.namiml.customer.CustomerJourneyState
|
|
15
|
-
import com.namiml.customer.NamiCustomerManager
|
|
16
|
-
import com.namiml.paywall.NamiPaywall
|
|
17
|
-
import com.namiml.paywall.NamiPaywallManager
|
|
18
|
-
import com.namiml.paywall.NamiSKU
|
|
19
|
-
import java.util.ArrayList
|
|
20
|
-
|
|
21
|
-
class NamiEmitter(reactContext: ReactApplicationContext) :
|
|
22
|
-
ReactContextBaseJavaModule(reactContext) {
|
|
23
|
-
|
|
24
|
-
override fun onCatalystInstanceDestroy() {
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
override fun getName(): String {
|
|
28
|
-
return NamiEmitter::class.java.simpleName
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
override fun canOverrideExistingModule(): Boolean {
|
|
32
|
-
return false
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
override fun initialize() {
|
|
36
|
-
// NamiPaywallManager.registerSignInListener { _, _, developerPaywallID ->
|
|
37
|
-
// Log.i(LOG_TAG, "Sign in clicked with developerPaywallID $developerPaywallID")
|
|
38
|
-
//
|
|
39
|
-
// emitSignInActivated(developerPaywallID)
|
|
40
|
-
// }
|
|
41
|
-
|
|
42
|
-
Log.i(LOG_TAG, "In Emitter Initialize()")
|
|
43
|
-
|
|
44
|
-
// NamiPaywallManager.registerPaywallRaiseListener { _, paywallData, products, developerPaywallId ->
|
|
45
|
-
// Log.i(
|
|
46
|
-
// LOG_TAG,
|
|
47
|
-
// "Products from registerPaywallRaiseListener callback are $products"
|
|
48
|
-
// )
|
|
49
|
-
//
|
|
50
|
-
// val sendProducts: List<NamiSKU> = products ?: ArrayList<NamiSKU>()
|
|
51
|
-
// emitPaywallRaise(paywallData, sendProducts, developerPaywallId)
|
|
52
|
-
// }
|
|
53
|
-
|
|
54
|
-
// NamiPurchaseManager.registerPurchasesChangedListener { list, namiPurchaseState, s ->
|
|
55
|
-
// emitPurchaseMade(list, namiPurchaseState, s)
|
|
56
|
-
// }
|
|
57
|
-
//
|
|
58
|
-
// NamiCustomerManager.registerCustomerJourneyChangedListener {
|
|
59
|
-
// emitCustomerJourneyChanged(it)
|
|
60
|
-
// }
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private fun emitCustomerJourneyChanged(customerJourneyState: CustomerJourneyState) {
|
|
64
|
-
Log.i(LOG_TAG, "Emitting CustomerJourneyChanged $customerJourneyState")
|
|
65
|
-
try {
|
|
66
|
-
reactApplicationContext
|
|
67
|
-
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
68
|
-
.emit("CustomerJourneyStateChanged", customerJourneyState.toDict())
|
|
69
|
-
} catch (e: Exception) {
|
|
70
|
-
Log.e(LOG_TAG, "Caught Exception: " + e.message)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
private fun emitPurchaseMade(
|
|
75
|
-
purchases: List<NamiPurchase>,
|
|
76
|
-
purchaseState: NamiPurchaseState,
|
|
77
|
-
errorString: String?
|
|
78
|
-
) {
|
|
79
|
-
val map = Arguments.createMap()
|
|
80
|
-
errorString?.let {
|
|
81
|
-
map.putString("error", errorString)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
val resultArray: WritableArray = WritableNativeArray()
|
|
85
|
-
for (purchase in purchases) {
|
|
86
|
-
resultArray.pushMap(purchase.toPurchaseDict())
|
|
87
|
-
}
|
|
88
|
-
map.putArray("purchases", resultArray)
|
|
89
|
-
|
|
90
|
-
val convertedState: String = when (purchaseState) {
|
|
91
|
-
NamiPurchaseState.PURCHASED -> {
|
|
92
|
-
"PURCHASED"
|
|
93
|
-
}
|
|
94
|
-
NamiPurchaseState.FAILED -> {
|
|
95
|
-
"FAILED"
|
|
96
|
-
}
|
|
97
|
-
NamiPurchaseState.CANCELLED -> {
|
|
98
|
-
"CANCELLED"
|
|
99
|
-
}
|
|
100
|
-
else -> {
|
|
101
|
-
"UNKNOWN"
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
map.putString("purchaseState", convertedState)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
Log.i(LOG_TAG, "Emitting purchase with state $convertedState")
|
|
108
|
-
try {
|
|
109
|
-
reactApplicationContext
|
|
110
|
-
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
111
|
-
.emit("PurchasesChanged", map)
|
|
112
|
-
} catch (e: Exception) {
|
|
113
|
-
Log.e(LOG_TAG, "Caught Exception: " + e.message)
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
private fun emitPaywallRaise(
|
|
118
|
-
namiPaywall: NamiPaywall,
|
|
119
|
-
productDicts: List<NamiSKU>,
|
|
120
|
-
paywallDeveloperID: String?
|
|
121
|
-
) {
|
|
122
|
-
|
|
123
|
-
Log.i(LOG_TAG, "Emitting paywall raise signal for developerID$paywallDeveloperID")
|
|
124
|
-
val map = Arguments.createMap().apply {
|
|
125
|
-
putString("developerPaywallID", paywallDeveloperID)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Populate paywall metadata map
|
|
129
|
-
// val paywallMap: WritableMap = namiPaywall.toNamiPaywallDict()
|
|
130
|
-
// map.putMap("paywallMetadata", paywallMap)
|
|
131
|
-
|
|
132
|
-
// Populate SKU details
|
|
133
|
-
val skusArray: WritableArray = Arguments.createArray()
|
|
134
|
-
|
|
135
|
-
for (sku in productDicts) {
|
|
136
|
-
skusArray.pushMap(sku.toSkuDict())
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
map.putArray("namiSkus", skusArray)
|
|
140
|
-
|
|
141
|
-
try {
|
|
142
|
-
reactApplicationContext
|
|
143
|
-
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
144
|
-
.emit("AppPaywallActivate", map)
|
|
145
|
-
} catch (e: Exception) {
|
|
146
|
-
Log.e(LOG_TAG, "Caught Exception: " + e.message)
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
private fun emitSignInActivated(paywallDeveloperID: String?) {
|
|
151
|
-
|
|
152
|
-
val map = Arguments.createMap().apply {
|
|
153
|
-
putString("developerPaywallID", paywallDeveloperID)
|
|
154
|
-
}
|
|
155
|
-
try {
|
|
156
|
-
reactApplicationContext
|
|
157
|
-
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
158
|
-
.emit("SignInActivate", map)
|
|
159
|
-
} catch (e: Exception) {
|
|
160
|
-
Log.e(LOG_TAG, "Caught Exception: " + e.message)
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
package/ios/NamiBridgeUtil.h
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// NamiBridgeUtil.h
|
|
3
|
-
// RNNami
|
|
4
|
-
//
|
|
5
|
-
// Copyright © 2020-2023 Nami ML Inc. All rights reserved.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
#import <Foundation/Foundation.h>
|
|
9
|
-
#import <NamiApple/NamiApple.h>
|
|
10
|
-
|
|
11
|
-
#ifndef NamiBridgeUtil_h
|
|
12
|
-
#define NamiBridgeUtil_h
|
|
13
|
-
|
|
14
|
-
@interface NamiBridgeUtil : NSObject
|
|
15
|
-
// Converts NamiMetaProduct into javascript compatible dictionary
|
|
16
|
-
+ (NSDictionary<NSString *,NSString *> *) skuToSKUDict:(NamiSKU *)product;
|
|
17
|
-
|
|
18
|
-
// Converts NamiMetaPurchase into javascript compatible dictionary
|
|
19
|
-
+ (NSDictionary<NSString *,NSString *> *) purchaseToPurchaseDict:(NamiPurchase *)purchase;
|
|
20
|
-
|
|
21
|
-
// Converts NSDate into javascript convertable (UTC) string
|
|
22
|
-
+ (NSString *)javascriptDateFromNSDate:(NSDate *)purchseTimestamp;
|
|
23
|
-
|
|
24
|
-
+ (NSDictionary<NSString *,NSString *> *) entitlementToEntitlementDict:(NamiEntitlement *)entitlement;
|
|
25
|
-
|
|
26
|
-
+ (NSArray *)stripPresentationPositionFromOrderedMetadataForPaywallMetaDict: (NSDictionary *)paywallMeta;
|
|
27
|
-
|
|
28
|
-
+ (NSDictionary<NSString *,NSString *> *) customerJourneyStateDict;
|
|
29
|
-
|
|
30
|
-
@end
|
|
31
|
-
|
|
32
|
-
#endif /* NamiBridgeUtil_h */
|
package/ios/NamiBridgeUtil.m
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// NamiBridgeUtil.m
|
|
3
|
-
// RNNami
|
|
4
|
-
//
|
|
5
|
-
// Copyright © 2020-2023 Nami ML Inc. All rights reserved.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
#import <Foundation/Foundation.h>
|
|
9
|
-
#import <NamiApple/NamiApple.h>
|
|
10
|
-
|
|
11
|
-
#import "NamiBridgeUtil.h"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@implementation NamiBridgeUtil : NSObject
|
|
15
|
-
|
|
16
|
-
+ (NSDictionary<NSString *,NSString *> *) skuToSKUDict:(NamiSKU *)sku {
|
|
17
|
-
NSMutableDictionary<NSString *,NSString *> *productDict = [NSMutableDictionary new];
|
|
18
|
-
|
|
19
|
-
productDict[@"skuIdentifier"] = sku.platformId;
|
|
20
|
-
|
|
21
|
-
SKProduct *productInt = sku.product;
|
|
22
|
-
productDict[@"localizedTitle"] = productInt.localizedTitle;
|
|
23
|
-
productDict[@"localizedDescription"] = productInt.localizedDescription;
|
|
24
|
-
productDict[@"localizedPrice"] = productInt.localizedPrice;
|
|
25
|
-
productDict[@"localizedMultipliedPrice"] = productInt.localizedMultipliedPrice;
|
|
26
|
-
productDict[@"price"] = productInt.price.stringValue;
|
|
27
|
-
productDict[@"priceLanguage"] = productInt.priceLocale.languageCode;
|
|
28
|
-
productDict[@"priceCountry"] = productInt.priceLocale.countryCode;
|
|
29
|
-
productDict[@"priceCurrency"] = productInt.priceLocale.currencyCode;
|
|
30
|
-
|
|
31
|
-
// Add smart text processed values for sku buttons to sku dictionary
|
|
32
|
-
// productDict[@"displayText"] = [sku localizedDisplayText];
|
|
33
|
-
// productDict[@"displaySubText"] = [sku localizedSubDisplayText];
|
|
34
|
-
|
|
35
|
-
if (@available(iOS 12.0, *)) {
|
|
36
|
-
if (productInt != nil && productInt.subscriptionGroupIdentifier != nil) {
|
|
37
|
-
productDict[@"subscriptionGroupIdentifier"] = [NSString stringWithString:productInt.subscriptionGroupIdentifier];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (@available(iOS 11.2, *)) {
|
|
42
|
-
SKProductSubscriptionPeriod *subscriptionPeriod = productInt.subscriptionPeriod;
|
|
43
|
-
|
|
44
|
-
if (subscriptionPeriod != NULL) {
|
|
45
|
-
NSUInteger numberOfUnits = subscriptionPeriod.numberOfUnits;
|
|
46
|
-
SKProductPeriodUnit periodUnit = subscriptionPeriod.unit;
|
|
47
|
-
NSString *convertedUnit = @"";
|
|
48
|
-
switch (periodUnit) {
|
|
49
|
-
case SKProductPeriodUnitDay:
|
|
50
|
-
convertedUnit = @"day";
|
|
51
|
-
break;
|
|
52
|
-
case SKProductPeriodUnitWeek:
|
|
53
|
-
convertedUnit = @"week";
|
|
54
|
-
break;
|
|
55
|
-
case SKProductPeriodUnitMonth:
|
|
56
|
-
convertedUnit = @"month";
|
|
57
|
-
break;
|
|
58
|
-
case SKProductPeriodUnitYear:
|
|
59
|
-
convertedUnit = @"year";
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
productDict[@"numberOfUnits"] = [NSString stringWithFormat:@"%lu", (unsigned long)numberOfUnits];
|
|
64
|
-
productDict[@"periodUnit"] = convertedUnit;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return productDict;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
+ (NSDictionary<NSString *,NSString *> *) purchaseToPurchaseDict:(NamiPurchase *)purchase {
|
|
72
|
-
NSMutableDictionary<NSString *,id> *purchaseDict = [NSMutableDictionary new];
|
|
73
|
-
|
|
74
|
-
purchaseDict[@"skuIdentifier"] = purchase.skuId;
|
|
75
|
-
purchaseDict[@"transactionIdentifier"] = purchase.transactionIdentifier;
|
|
76
|
-
|
|
77
|
-
// Removed, not sure why, should add back in when possible.
|
|
78
|
-
// purchaseDict[@"purchaseInitiatedTimestamp"] = [self javascriptDateFromNSDate:purchase.purchaseInitiatedTimestamp];
|
|
79
|
-
|
|
80
|
-
NSDate *subscriptionExpirationDate = purchase.expires;
|
|
81
|
-
if (subscriptionExpirationDate != nil) {
|
|
82
|
-
purchaseDict[@"subscriptionExpirationDate"] = [self javascriptDateFromNSDate:subscriptionExpirationDate];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
NSString *convertedSourceString = @"UNKNOWN";
|
|
86
|
-
switch (purchase.purchaseSource) {
|
|
87
|
-
case 0:
|
|
88
|
-
convertedSourceString = @"EXTERNAL";
|
|
89
|
-
break;
|
|
90
|
-
case 1:
|
|
91
|
-
convertedSourceString = @"NAMI_RULES";
|
|
92
|
-
break;
|
|
93
|
-
case 2:
|
|
94
|
-
convertedSourceString = @"USER";
|
|
95
|
-
break;
|
|
96
|
-
default:
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
purchaseDict[@"purchaseSource"] = convertedSourceString;
|
|
100
|
-
|
|
101
|
-
// NamiSKU *purchaseSku = [purchase ]
|
|
102
|
-
|
|
103
|
-
return purchaseDict;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
// Strip out presention_position from all listed sku items in the sku_ordered_metadata array
|
|
108
|
-
+ (NSArray *)stripPresentationPositionFromOrderedMetadataForPaywallMetaDict: (NSDictionary *)paywallMeta {
|
|
109
|
-
NSArray *baseSkuArray = [paywallMeta objectForKey:@"sku_ordered_metadata"];
|
|
110
|
-
NSMutableArray *newOrderedMetadata = [NSMutableArray new];
|
|
111
|
-
|
|
112
|
-
if ( [baseSkuArray isKindOfClass:[NSArray class]] ) {
|
|
113
|
-
for (NSDictionary *baseSkuDict in baseSkuArray) {
|
|
114
|
-
NSMutableDictionary *skuFormattingDict = [NSMutableDictionary dictionaryWithDictionary:baseSkuDict];
|
|
115
|
-
[skuFormattingDict removeObjectForKey:@"presentation_position"];
|
|
116
|
-
[newOrderedMetadata addObject:skuFormattingDict];
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return newOrderedMetadata;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
+ (NSDictionary<NSString *,NSString *> *) entitlementToEntitlementDict:(NamiEntitlement *)entitlement {
|
|
123
|
-
NSMutableDictionary<NSString *,id> *entitlementDict = [NSMutableDictionary new];
|
|
124
|
-
NSLog(@"Converting entitlement %@", entitlement);
|
|
125
|
-
entitlementDict[@"referenceID"] = [entitlement referenceId];
|
|
126
|
-
entitlementDict[@"namiID"] = [entitlement namiId] ? [entitlement namiId] : @"";
|
|
127
|
-
entitlementDict[@"desc"] = [entitlement desc] ? [entitlement desc] : @"";
|
|
128
|
-
entitlementDict[@"name"] = [entitlement name] ? [entitlement name] : @"";
|
|
129
|
-
|
|
130
|
-
if (entitlementDict[@"referenceID"] == nil || [[entitlement referenceId] length] == 0) {
|
|
131
|
-
NSLog(@"NamiBridge: Bad entitlement in system, empty referenceID.");
|
|
132
|
-
return nil;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
NSArray <NamiPurchase *>*activePurchases = [entitlement activePurchases];
|
|
136
|
-
NSMutableArray *convertedActivePurchases = [NSMutableArray array];
|
|
137
|
-
for (NamiPurchase *purchase in activePurchases) {
|
|
138
|
-
NSDictionary *purchaseDict = [NamiBridgeUtil purchaseToPurchaseDict:purchase];
|
|
139
|
-
if (purchaseDict != nil) {
|
|
140
|
-
[convertedActivePurchases addObject:purchaseDict];
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
entitlementDict[@"activePurchases"] = convertedActivePurchases;
|
|
144
|
-
|
|
145
|
-
NSArray <NamiSKU *>*purchasedSKUs = [entitlement purchasedSkus];
|
|
146
|
-
NSMutableArray *convertedPurchasedSKUs = [NSMutableArray array];
|
|
147
|
-
for (NamiSKU *sku in purchasedSKUs) {
|
|
148
|
-
NSDictionary *skuDict = [NamiBridgeUtil skuToSKUDict:sku];
|
|
149
|
-
if (skuDict != nil) {
|
|
150
|
-
[convertedPurchasedSKUs addObject:skuDict];
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
entitlementDict[@"purchasedSKUs"] = convertedPurchasedSKUs;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
NSArray <NamiSKU *>*relatedSKUs = [entitlement relatedSkus];
|
|
157
|
-
NSMutableArray *convertedRelatedSKUs = [NSMutableArray array];
|
|
158
|
-
for (NamiSKU *sku in relatedSKUs) {
|
|
159
|
-
NSDictionary *skuDict = [NamiBridgeUtil skuToSKUDict:sku];
|
|
160
|
-
if (skuDict != nil) {
|
|
161
|
-
[convertedRelatedSKUs addObject:skuDict];
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
entitlementDict[@"relatedSKUs"] = convertedRelatedSKUs;
|
|
165
|
-
|
|
166
|
-
NamiPurchase *lastPurchase;
|
|
167
|
-
for (NamiPurchase *purchase in [entitlement activePurchases]) {
|
|
168
|
-
if (lastPurchase == NULL || ([lastPurchase purchaseInitiatedTimestamp] < [purchase purchaseInitiatedTimestamp])) {
|
|
169
|
-
lastPurchase = purchase;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (lastPurchase != NULL) {
|
|
173
|
-
// entitlementDict[@"latestPurchase"] = [NamiBridgeUtil purchaseToPurchaseDict:lastPurchase];
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
NSString *lastPurchaseSKUID = [lastPurchase skuId];
|
|
177
|
-
|
|
178
|
-
NamiSKU *lastPurchasedSKU;
|
|
179
|
-
if (lastPurchaseSKUID != NULL ) {
|
|
180
|
-
for (NamiSKU *sku in [entitlement purchasedSkus]) {
|
|
181
|
-
if ( [[sku platformId] isEqualToString:lastPurchaseSKUID] ) {
|
|
182
|
-
lastPurchasedSKU = sku;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (lastPurchasedSKU != NULL) {
|
|
188
|
-
lastPurchasedSKU = [[entitlement purchasedSkus] lastObject];
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (lastPurchasedSKU != NULL) {
|
|
192
|
-
// entitlementDict[@"lastPurchasedSKU"] = [NamiBridgeUtil skuToSKUDict:lastPurchasedSKU];
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return entitlementDict;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
+ (NSString *)javascriptDateFromNSDate:(NSDate *)purchaseTimestamp {
|
|
201
|
-
NSTimeZone *UTC = [NSTimeZone timeZoneWithAbbreviation: @"UTC"];
|
|
202
|
-
NSISO8601DateFormatOptions options = NSISO8601DateFormatWithInternetDateTime | NSISO8601DateFormatWithDashSeparatorInDate | NSISO8601DateFormatWithColonSeparatorInTime | NSISO8601DateFormatWithTimeZone;
|
|
203
|
-
|
|
204
|
-
return [NSISO8601DateFormatter stringFromDate:purchaseTimestamp timeZone:UTC formatOptions:options];
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
+ (NSDictionary<NSString *,NSString *> *) customerJourneyStateDict {
|
|
209
|
-
CustomerJourneyState *journeyState = [NamiCustomerManager journeyState];
|
|
210
|
-
|
|
211
|
-
BOOL formerSubscriber = [journeyState formerSubscriber];
|
|
212
|
-
BOOL inGracePeriod = [journeyState inGracePeriod];
|
|
213
|
-
BOOL inTrialPeriod = [journeyState inTrialPeriod];
|
|
214
|
-
BOOL inIntroOfferPeriod = [journeyState inIntroOfferPeriod];
|
|
215
|
-
|
|
216
|
-
BOOL isCancelled = [journeyState isCancelled];
|
|
217
|
-
BOOL inPause = [journeyState inPause];
|
|
218
|
-
BOOL inAccountHold = [journeyState inAccountHold];
|
|
219
|
-
|
|
220
|
-
NSDictionary *journeyDict = @{@"formerSubscriber":@(formerSubscriber),
|
|
221
|
-
@"inGracePeriod":@(inGracePeriod),
|
|
222
|
-
@"inTrialPeriod":@(inTrialPeriod),
|
|
223
|
-
@"inIntroOfferPeriod":@(inIntroOfferPeriod),
|
|
224
|
-
@"isCancelled":@(isCancelled),
|
|
225
|
-
@"inPause":@(inPause),
|
|
226
|
-
@"inAccountHold":@(inAccountHold)
|
|
227
|
-
};
|
|
228
|
-
return journeyDict;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
@end
|