react-native-nami-sdk 3.0.8 → 3.0.9
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/android/build.gradle +1 -1
- package/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt +2 -2
- package/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt +8 -5
- package/android/src/main/java/com/nami/reactlibrary/NamiCustomerManagerBridge.kt +16 -6
- package/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt +99 -4
- package/ios/Nami.m +1 -1
- package/ios/NamiCampaignManagerBridge.swift +6 -1
- package/ios/NamiCustomerManager.m +4 -0
- package/ios/NamiCustomerManager.swift +10 -0
- package/ios/Podfile +1 -1
- package/ios/RNNami.xcodeproj/project.pbxproj +1 -5
- package/package.json +1 -1
- package/react-native-nami-sdk.podspec +1 -1
- package/src/NamiCampaignManager.d.ts +4 -1
- package/src/NamiCampaignManager.js +12 -1
- package/src/NamiCustomerManager.d.ts +2 -0
- package/src/NamiPaywallManager.d.ts +27 -2
- package/src/NamiPaywallManager.js +9 -0
package/android/build.gradle
CHANGED
|
@@ -81,7 +81,7 @@ dependencies {
|
|
|
81
81
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
|
82
82
|
|
|
83
83
|
implementation 'com.github.jeziellago:compose-markdown:0.3.0'
|
|
84
|
-
implementation "com.namiml:sdk-android:3.0.
|
|
84
|
+
implementation "com.namiml:sdk-android:3.0.9"
|
|
85
85
|
|
|
86
86
|
implementation 'com.facebook.react:react-native:+' // From node_modules
|
|
87
87
|
}
|
|
@@ -127,7 +127,7 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
127
127
|
} else {
|
|
128
128
|
Arguments.createArray()
|
|
129
129
|
}
|
|
130
|
-
val settingsList = mutableListOf("extendedClientInfo:react-native:3.0.
|
|
130
|
+
val settingsList = mutableListOf("extendedClientInfo:react-native:3.0.9")
|
|
131
131
|
namiCommandsReact?.toArrayList()?.filterIsInstance<String>()?.let { commandsFromReact ->
|
|
132
132
|
settingsList.addAll(commandsFromReact)
|
|
133
133
|
}
|
|
@@ -145,4 +145,4 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
145
145
|
completion.invoke(resultMap)
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
}
|
|
148
|
+
}
|
|
@@ -34,21 +34,21 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
34
34
|
reactApplicationContext.runOnUiQueueThread {
|
|
35
35
|
if (label != null) {
|
|
36
36
|
NamiCampaignManager.launch(currentActivity!!, label,
|
|
37
|
-
paywallActionCallback = { action, sku, purchaseError, purchases ->
|
|
38
|
-
handlePaywallCallback(action, sku, purchaseError, purchases, actionCallback)
|
|
37
|
+
paywallActionCallback = { campaignId, campaignLabel, paywallId, action, sku, purchaseError, purchases ->
|
|
38
|
+
handlePaywallCallback(campaignId, campaignLabel, paywallId, action, sku, purchaseError, purchases, actionCallback)
|
|
39
39
|
}
|
|
40
40
|
) { result -> handleResult(result, resultCallback) }
|
|
41
41
|
} else {
|
|
42
42
|
NamiCampaignManager.launch(currentActivity!!,
|
|
43
|
-
paywallActionCallback = { action, sku,purchaseError, purchases ->
|
|
44
|
-
handlePaywallCallback(action, sku, purchaseError, purchases, actionCallback)
|
|
43
|
+
paywallActionCallback = { campaignId, campaignLabel, paywallId, action, sku,purchaseError, purchases ->
|
|
44
|
+
handlePaywallCallback(campaignId, campaignLabel, paywallId, action, sku, purchaseError, purchases, actionCallback)
|
|
45
45
|
}
|
|
46
46
|
) { result -> handleResult(result, resultCallback) }
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
private fun handlePaywallCallback(action: NamiPaywallAction, sku: NamiSKU?, purchaseError: String?, purchases: List<NamiPurchase>?, actionCallback: Callback){
|
|
51
|
+
private fun handlePaywallCallback(campaignId: String, campaignLabel: String?, paywallId: String, action: NamiPaywallAction, sku: NamiSKU?, purchaseError: String?, purchases: List<NamiPurchase>?, actionCallback: Callback){
|
|
52
52
|
val actionString = action.toString()
|
|
53
53
|
val skuString = sku?.skuId.orEmpty()
|
|
54
54
|
val purchasesArray: WritableArray = WritableNativeArray()
|
|
@@ -58,6 +58,9 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
val resultMap = Arguments.createMap()
|
|
61
|
+
resultMap.putString("campaignId", campaignId)
|
|
62
|
+
resultMap.putString("campaignLabel", campaignLabel)
|
|
63
|
+
resultMap.putString("paywallId", paywallId)
|
|
61
64
|
resultMap.putString("action", actionString)
|
|
62
65
|
resultMap.putString("skuId", skuString)
|
|
63
66
|
resultMap.putString("purchaseError", purchaseError)
|
|
@@ -47,15 +47,25 @@ class NamiCustomerManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
47
47
|
NamiCustomerManager.clearAllCustomerAttributes()
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
@ReactMethod
|
|
51
|
+
fun clearCustomerDataPlatformId(){
|
|
52
|
+
NamiCustomerManager.clearCustomerDataPlatformId()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@ReactMethod
|
|
56
|
+
fun setCustomerDataPlatformId(cdpId: String){
|
|
57
|
+
NamiCustomerManager.setCustomerDataPlatformId(cdpId)
|
|
58
|
+
}
|
|
59
|
+
|
|
50
60
|
@ReactMethod
|
|
51
61
|
fun journeyState(promise: Promise){
|
|
52
62
|
val journeyState = NamiCustomerManager.journeyState()
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
63
|
+
if (journeyState == null) {
|
|
64
|
+
promise.resolve(null)
|
|
65
|
+
} else {
|
|
66
|
+
val handledJourneyState = journeyStateToReadableMap(journeyState)
|
|
67
|
+
promise.resolve(handledJourneyState)
|
|
68
|
+
}
|
|
59
69
|
}
|
|
60
70
|
|
|
61
71
|
@ReactMethod
|
|
@@ -6,8 +6,10 @@ import android.util.Log
|
|
|
6
6
|
import com.android.billingclient.api.Purchase
|
|
7
7
|
import com.facebook.react.bridge.*
|
|
8
8
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
9
|
-
import com.namiml.paywall
|
|
10
|
-
import com.namiml.paywall.
|
|
9
|
+
import com.namiml.paywall.*
|
|
10
|
+
import com.namiml.paywall.model.NamiPurchaseSuccess
|
|
11
|
+
import java.text.SimpleDateFormat
|
|
12
|
+
import java.util.Date
|
|
11
13
|
|
|
12
14
|
class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
13
15
|
ReactContextBaseJavaModule(reactContext), ActivityEventListener {
|
|
@@ -19,8 +21,101 @@ class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
@ReactMethod
|
|
22
|
-
fun buySkuComplete(
|
|
23
|
-
|
|
24
|
+
fun buySkuComplete(dict: ReadableMap, storeType: String) {
|
|
25
|
+
var product = dict.getMap("product")
|
|
26
|
+
var name = product?.getString("name")
|
|
27
|
+
var featured = product?.getBoolean("featured")
|
|
28
|
+
var productId = product?.getString("id")
|
|
29
|
+
var skuId = product?.getString("skuId")
|
|
30
|
+
var typeInt = product?.getInt("type")
|
|
31
|
+
var purchaseSourceString = dict.getString("purchaseSource")
|
|
32
|
+
var purchaseDateInt = dict.getInt("purchaseDate")
|
|
33
|
+
var expiresDateInt = dict.getInt("expiresDate")
|
|
34
|
+
val type = when (typeInt) {
|
|
35
|
+
0 -> {
|
|
36
|
+
NamiSKUType.UNKNOWN
|
|
37
|
+
}
|
|
38
|
+
1 -> {
|
|
39
|
+
NamiSKUType.SUBSCRIPTION
|
|
40
|
+
}
|
|
41
|
+
2 -> {
|
|
42
|
+
NamiSKUType.ONE_TIME_PURCHASE
|
|
43
|
+
}
|
|
44
|
+
else -> {
|
|
45
|
+
NamiSKUType.UNKNOWN
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
val purchaseSource = when (purchaseSourceString) {
|
|
50
|
+
"CAMPAIGN" -> {
|
|
51
|
+
NamiPurchaseSource.CAMPAIGN
|
|
52
|
+
}
|
|
53
|
+
"MARKETPLACE" -> {
|
|
54
|
+
NamiPurchaseSource.MARKETPLACE
|
|
55
|
+
}
|
|
56
|
+
"UNKNOWN" -> {
|
|
57
|
+
NamiPurchaseSource.UNKNOWN
|
|
58
|
+
}
|
|
59
|
+
else -> {
|
|
60
|
+
NamiPurchaseSource.UNKNOWN
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (name != null && skuId != null && featured != null) {
|
|
65
|
+
val namiSku = NamiSKU(
|
|
66
|
+
skuId = skuId,
|
|
67
|
+
skuDetails = null,
|
|
68
|
+
amazonProduct = null,
|
|
69
|
+
id = productId,
|
|
70
|
+
type = type,
|
|
71
|
+
name = name,
|
|
72
|
+
featured = featured,
|
|
73
|
+
rawDisplayText = null,
|
|
74
|
+
rawSubDisplayText = null,
|
|
75
|
+
entitlements = emptyList(),
|
|
76
|
+
variables = null
|
|
77
|
+
)
|
|
78
|
+
val purchaseDate = Date(purchaseDateInt * 1000L)
|
|
79
|
+
var expiresDate = Date(expiresDateInt * 1000L )
|
|
80
|
+
var purchaseSuccess: NamiPurchaseSuccess? = null;
|
|
81
|
+
if (storeType == "GooglePlay") {
|
|
82
|
+
var purchaseToken = dict.getString("purchaseToken")
|
|
83
|
+
var orderId = dict.getString("orderId")
|
|
84
|
+
if (purchaseToken != null && orderId != null) {
|
|
85
|
+
purchaseSuccess = NamiPurchaseSuccess.GooglePlay(
|
|
86
|
+
product = namiSku,
|
|
87
|
+
expiresDate = expiresDate,
|
|
88
|
+
purchaseDate = purchaseDate,
|
|
89
|
+
purchaseSource = purchaseSource,
|
|
90
|
+
description = null,
|
|
91
|
+
orderId = orderId,
|
|
92
|
+
purchaseToken = purchaseToken,
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
} else if (storeType == "Amazon") {
|
|
96
|
+
var receiptId = dict.getString("receiptId")
|
|
97
|
+
var localizedPrice = dict.getString("localizedPrice")
|
|
98
|
+
var userId = dict.getString("userId")
|
|
99
|
+
var marketplace = dict.getString("marketplace")
|
|
100
|
+
if (receiptId != null && localizedPrice != null && userId != null && marketplace != null) {
|
|
101
|
+
purchaseSuccess = NamiPurchaseSuccess.Amazon(
|
|
102
|
+
product = namiSku,
|
|
103
|
+
expiresDate = expiresDate,
|
|
104
|
+
purchaseDate = purchaseDate,
|
|
105
|
+
purchaseSource = purchaseSource,
|
|
106
|
+
description = null,
|
|
107
|
+
receiptId = receiptId,
|
|
108
|
+
localizedPrice = localizedPrice,
|
|
109
|
+
userId = userId,
|
|
110
|
+
marketplace = marketplace,
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (purchaseSuccess != null) {
|
|
116
|
+
NamiPaywallManager.buySkuComplete(currentActivity!!, purchaseSuccess)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
24
119
|
}
|
|
25
120
|
|
|
26
121
|
|
package/ios/Nami.m
CHANGED
|
@@ -67,7 +67,7 @@ RCT_EXPORT_METHOD(configure: (NSDictionary *)configDict completion: (RCTResponse
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
// Start commands with header iformation for Nami to let them know this is a React client.
|
|
70
|
-
NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.0.
|
|
70
|
+
NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.0.9"]];
|
|
71
71
|
|
|
72
72
|
// Add additional namiCommands app may have sent in.
|
|
73
73
|
NSObject *appCommandStrings = configDict[@"namiCommands"];
|
|
@@ -31,7 +31,7 @@ class RNNamiCampaignManager: RCTEventEmitter {
|
|
|
31
31
|
func launch(label: String?, callback: @escaping RCTResponseSenderBlock, paywallCallback _: @escaping RCTResponseSenderBlock) {
|
|
32
32
|
NamiCampaignManager.launch(label: label, launchHandler: { success, error in
|
|
33
33
|
callback([success, error?._code as Any])
|
|
34
|
-
}, paywallActionHandler: { action, sku, purchaseError, purchases in
|
|
34
|
+
}, paywallActionHandler: { campaignId, campaignLabel, paywallId, action, sku, purchaseError, purchases in
|
|
35
35
|
let actionString: String
|
|
36
36
|
switch action {
|
|
37
37
|
case .show_paywall:
|
|
@@ -58,6 +58,8 @@ class RNNamiCampaignManager: RCTEventEmitter {
|
|
|
58
58
|
actionString = "PURCHASE_CANCELLED"
|
|
59
59
|
case .purchase_unknown:
|
|
60
60
|
actionString = "PURCHASE_UNKNOWN"
|
|
61
|
+
case .show_paywall:
|
|
62
|
+
actionString = "SHOW_PAYWALL"
|
|
61
63
|
@unknown default:
|
|
62
64
|
actionString = "PURCHASE_UNKNOWN"
|
|
63
65
|
}
|
|
@@ -65,6 +67,9 @@ class RNNamiCampaignManager: RCTEventEmitter {
|
|
|
65
67
|
let errorSting = purchaseError?.localizedDescription
|
|
66
68
|
let dictionaries = purchases.map { purchase in NamiBridgeUtil.purchase(toPurchaseDict: purchase) }
|
|
67
69
|
let payload: [String: Any?] = [
|
|
70
|
+
"campaignId": campaignId,
|
|
71
|
+
"campaignLabel": campaignLabel,
|
|
72
|
+
"paywallId": paywallId,
|
|
68
73
|
"action": actionString,
|
|
69
74
|
"skuId": skuId,
|
|
70
75
|
"purchaseError": errorSting,
|
|
@@ -17,6 +17,10 @@ RCT_EXTERN_METHOD(clearCustomerAttribute:(NSString *)key)
|
|
|
17
17
|
|
|
18
18
|
RCT_EXTERN_METHOD(clearAllCustomerAttributes)
|
|
19
19
|
|
|
20
|
+
RCT_EXTERN_METHOD(setCustomerDataPlatformId:(NSString *)platformId)
|
|
21
|
+
|
|
22
|
+
RCT_EXTERN_METHOD(clearCustomerDataPlatformId)
|
|
23
|
+
|
|
20
24
|
RCT_EXTERN_METHOD(journeyState:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
21
25
|
|
|
22
26
|
RCT_EXTERN_METHOD(isLoggedIn:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
@@ -49,6 +49,16 @@ class RNNamiCustomerManager: RCTEventEmitter {
|
|
|
49
49
|
NamiCustomerManager.clearAllCustomerAttributes()
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
@objc(setCustomerDataPlatformId:)
|
|
53
|
+
func setCustomerDataPlatformId(cdpId: String) {
|
|
54
|
+
NamiCustomerManager.setCustomerDataPlatformId(with: cdpId)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@objc(clearCustomerDataPlatformId)
|
|
58
|
+
func clearCustomerDataPlatformId() {
|
|
59
|
+
NamiCustomerManager.clearCustomerDataPlatformId()
|
|
60
|
+
}
|
|
61
|
+
|
|
52
62
|
@objc(journeyState:rejecter:)
|
|
53
63
|
func journeyState(resolve: @escaping RCTPromiseResolveBlock, reject _: @escaping RCTPromiseRejectBlock) {
|
|
54
64
|
if let journeyState = NamiCustomerManager.journeyState() {
|
package/ios/Podfile
CHANGED
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
EB75992124F031E900430D98 /* NamiCustomerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = EB75992024F031E900430D98 /* NamiCustomerManager.m */; };
|
|
16
16
|
EB7B50CE243E314900EBA6B7 /* NamiEntitlementManagerBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = EB7B50CD243E314900EBA6B7 /* NamiEntitlementManagerBridge.m */; };
|
|
17
17
|
EBC59E5D23C5514B008A123A /* Nami.m in Sources */ = {isa = PBXBuildFile; fileRef = EBC59E5C23C5514B008A123A /* Nami.m */; };
|
|
18
|
-
EBC59E6023C7E2EC008A123A /* NamiAnalyticsEmitter.m in Sources */ = {isa = PBXBuildFile; fileRef = EBC59E5F23C7E2EC008A123A /* NamiAnalyticsEmitter.m */; };
|
|
19
18
|
EBC59E6323C7F634008A123A /* NamiBridgeUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = EBC59E6223C7F634008A123A /* NamiBridgeUtil.m */; };
|
|
20
19
|
EBEEAC10243C29C800E01389 /* NamiMLManagerBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = EBEEAC0F243C29C800E01389 /* NamiMLManagerBridge.m */; };
|
|
21
20
|
FA3AB38529E009F300FD2E8D /* NamiPaywallManagerBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA3AB38429E009F300FD2E8D /* NamiPaywallManagerBridge.swift */; };
|
|
@@ -51,7 +50,6 @@
|
|
|
51
50
|
EB75992024F031E900430D98 /* NamiCustomerManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NamiCustomerManager.m; sourceTree = "<group>"; };
|
|
52
51
|
EB7B50CD243E314900EBA6B7 /* NamiEntitlementManagerBridge.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NamiEntitlementManagerBridge.m; sourceTree = "<group>"; };
|
|
53
52
|
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
53
|
EBC59E6223C7F634008A123A /* NamiBridgeUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NamiBridgeUtil.m; sourceTree = "<group>"; };
|
|
56
54
|
EBC59E6423C7F7A0008A123A /* NamiBridgeUtil.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NamiBridgeUtil.h; sourceTree = "<group>"; };
|
|
57
55
|
EBEEAC0F243C29C800E01389 /* NamiMLManagerBridge.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NamiMLManagerBridge.m; sourceTree = "<group>"; };
|
|
@@ -99,7 +97,6 @@
|
|
|
99
97
|
B3E7B5891CC2AC0600A0062D /* RNNami.m */,
|
|
100
98
|
EBC59E5C23C5514B008A123A /* Nami.m */,
|
|
101
99
|
EB1C9AFA23BE9C5700CAD548 /* NamiEmitter.m */,
|
|
102
|
-
EBC59E5F23C7E2EC008A123A /* NamiAnalyticsEmitter.m */,
|
|
103
100
|
EBEEAC0F243C29C800E01389 /* NamiMLManagerBridge.m */,
|
|
104
101
|
134814211AA4EA7D00B7C361 /* Products */,
|
|
105
102
|
82475599A9F3B58440ACDC6E /* Frameworks */,
|
|
@@ -254,7 +251,6 @@
|
|
|
254
251
|
buildActionMask = 2147483647;
|
|
255
252
|
files = (
|
|
256
253
|
FA3AB38529E009F300FD2E8D /* NamiPaywallManagerBridge.swift in Sources */,
|
|
257
|
-
EBC59E6023C7E2EC008A123A /* NamiAnalyticsEmitter.m in Sources */,
|
|
258
254
|
EBC59E5D23C5514B008A123A /* Nami.m in Sources */,
|
|
259
255
|
EB1C9AFB23BE9C5700CAD548 /* NamiPurchaseManagerBridge.m in Sources */,
|
|
260
256
|
EB1C9AFC23BE9C5700CAD548 /* NamiPaywallManagerBridge.m in Sources */,
|
|
@@ -297,7 +293,7 @@
|
|
|
297
293
|
COPY_PHASE_STRIP = NO;
|
|
298
294
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
299
295
|
ENABLE_TESTABILITY = YES;
|
|
300
|
-
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
|
|
296
|
+
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 ";
|
|
301
297
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
|
302
298
|
GCC_DYNAMIC_NO_PIC = NO;
|
|
303
299
|
GCC_NO_COMMON_BLOCKS = YES;
|
package/package.json
CHANGED
|
@@ -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
|
-
|
|
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(
|
|
@@ -2,7 +2,11 @@ import { EmitterSubscription } from "react-native";
|
|
|
2
2
|
import { NamiSKU } from "./types";
|
|
3
3
|
|
|
4
4
|
export const NamiPaywallManager: {
|
|
5
|
-
|
|
5
|
+
buySkuCompleteIos: (purchaseSuccess: PurchaseSuccessIos) => void;
|
|
6
|
+
buySkuCompleteAmazon: (purchaseSuccess: PurchaseSuccessAmazon) => void;
|
|
7
|
+
buySkuCompleteGooglePlay: (
|
|
8
|
+
purchaseSuccess: PurchaseSuccessGooglePlay
|
|
9
|
+
) => void;
|
|
6
10
|
dismiss: (animated: boolean, callback: () => void) => void;
|
|
7
11
|
displayedViewController: () => void;
|
|
8
12
|
renderCustomUiHandler: () => any;
|
|
@@ -15,7 +19,7 @@ export const NamiPaywallManager: {
|
|
|
15
19
|
) => EmitterSubscription["remove"];
|
|
16
20
|
};
|
|
17
21
|
|
|
18
|
-
export type
|
|
22
|
+
export type PurchaseSuccessIos = {
|
|
19
23
|
product: PurchaseSuccessProduct;
|
|
20
24
|
transactionID: string;
|
|
21
25
|
originalTransactionID: string;
|
|
@@ -27,6 +31,26 @@ export type PurchaseSuccess = {
|
|
|
27
31
|
locale: string;
|
|
28
32
|
};
|
|
29
33
|
|
|
34
|
+
export type PurchaseSuccessGooglePlay = {
|
|
35
|
+
product: PurchaseSuccessProduct;
|
|
36
|
+
orderId: string;
|
|
37
|
+
purchaseDate: number;
|
|
38
|
+
expiresDate?: number;
|
|
39
|
+
purchaseToken: string;
|
|
40
|
+
purchaseSource: "CAMPAIGN" | "MARKETPLACE" | "UNKNOWN";
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type PurchaseSuccessAmazon = {
|
|
44
|
+
product: PurchaseSuccessProduct;
|
|
45
|
+
purchaseDate: number;
|
|
46
|
+
expiresDate?: number;
|
|
47
|
+
purchaseSource: "CAMPAIGN" | "MARKETPLACE" | "UNKNOWN";
|
|
48
|
+
receiptId: string;
|
|
49
|
+
localizedPrice: string;
|
|
50
|
+
userId: string;
|
|
51
|
+
marketplace: string;
|
|
52
|
+
};
|
|
53
|
+
|
|
30
54
|
export type PurchaseSuccessProduct = {
|
|
31
55
|
id: string;
|
|
32
56
|
platformID: string;
|
|
@@ -54,4 +78,5 @@ export enum NamiPaywallAction {
|
|
|
54
78
|
PURCHASE_PENDING = "PURCHASE_PENDING",
|
|
55
79
|
PURCHASE_UNKNOWN = "PURCHASE_UNKNOWN",
|
|
56
80
|
PURCHASE_DEFERRED = "PURCHASE_DEFERRED",
|
|
81
|
+
SHOW_PAYWALL = "SHOW_PAYWALL",
|
|
57
82
|
}
|
|
@@ -6,6 +6,15 @@ export const NamiPaywallManager = {
|
|
|
6
6
|
paywallEmitter: new NativeEventEmitter(RNNamiPaywallManager),
|
|
7
7
|
...RNNamiPaywallManager,
|
|
8
8
|
...NamiPaywallManagerBridge,
|
|
9
|
+
buySkuCompleteIos(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",
|