react-native-nami-sdk 3.0.13 → 3.0.15

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.
@@ -84,7 +84,7 @@ dependencies {
84
84
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
85
85
 
86
86
  implementation 'com.github.jeziellago:compose-markdown:0.3.0'
87
- implementation "com.namiml:sdk-android:3.0.16"
87
+ implementation "com.namiml:sdk-android:3.0.18"
88
88
 
89
89
  implementation 'com.facebook.react:react-native:+' // From node_modules
90
90
  coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5"
@@ -115,7 +115,7 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) :
115
115
  } else {
116
116
  Arguments.createArray()
117
117
  }
118
- val settingsList = mutableListOf("extendedClientInfo:react-native:3.0.13")
118
+ val settingsList = mutableListOf("extendedClientInfo:react-native:3.0.15")
119
119
  namiCommandsReact?.toArrayList()?.filterIsInstance<String>()?.let { commandsFromReact ->
120
120
  settingsList.addAll(commandsFromReact)
121
121
  }
@@ -11,9 +11,28 @@ import com.namiml.campaign.NamiCampaign
11
11
  import com.namiml.campaign.NamiCampaignManager
12
12
  import com.namiml.paywall.NamiSKU
13
13
  import com.namiml.paywall.model.NamiPaywallAction
14
+ import com.namiml.paywall.model.PaywallLaunchContext
14
15
 
15
16
  class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
16
17
  ReactContextBaseJavaModule(reactContext), ActivityEventListener {
18
+ // handlePaywallCallback metadata
19
+ companion object {
20
+ const val CAMPAIGN_ID = "campaignId"
21
+ const val CAMPAIGN_LABEL = "campaignLabel"
22
+ const val PAYWALL_ID = "paywallId"
23
+ const val ACTION = "action"
24
+ const val SKU_ID = "skuId"
25
+ const val PURCHASE_ERROR = "purchaseError"
26
+ const val PURCHASES = "purchases"
27
+ const val CAMPAIGN_NAME = "campaignName"
28
+ const val CAMPAIGN_TYPE = "campaignType"
29
+ const val CAMPAIGN_URL = "campaignUrl"
30
+ const val PAYWALL_NAME = "paywallName"
31
+ const val SEGMENT_ID = "segmentId"
32
+ const val EXTERNAL_SEGMENT_ID = "externalSegmentId"
33
+ const val DEEP_LINK_URL = "deeplinkUrl"
34
+ const val _RESULT_CAMPAIGN = "ResultCampaign"
35
+ }
17
36
 
18
37
  override fun getName(): String {
19
38
  return "RNNamiCampaignManager"
@@ -29,28 +48,93 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
29
48
  }
30
49
 
31
50
  @ReactMethod
32
- fun launch(label: String?, resultCallback: Callback, actionCallback: Callback) {
51
+ fun launch(label: String?, context: ReadableMap?, resultCallback: Callback, actionCallback: Callback) {
33
52
  var theActivity: Activity? = null
34
53
  if (reactApplicationContext.hasCurrentActivity()) {
35
54
  theActivity = reactApplicationContext.getCurrentActivity()
36
55
  }
37
56
 
57
+ var paywallLaunchContext: PaywallLaunchContext? = null
58
+ if (context != null) {
59
+
60
+ val productGroups: MutableList<String> = mutableListOf()
61
+ val customAttributes: MutableMap<String, String> = mutableMapOf()
62
+
63
+ if (context.hasKey("productGroups")) {
64
+ val groups = context.getArray("productGroups")
65
+ if (groups != null) {
66
+ for (i in 0 until groups.size()) {
67
+ val groupString = groups.getString(i)
68
+ if (groupString != null) {
69
+ productGroups.add(groupString)
70
+ }
71
+
72
+ }
73
+ }
74
+ Log.d(LOG_TAG, "productGroups $productGroups")
75
+ }
76
+
77
+ if (context.hasKey("customAttributes")) {
78
+ val attr = context.getMap("customAttributes")
79
+ if (attr != null) {
80
+ val keyIterator = attr.keySetIterator()
81
+ while (keyIterator.hasNextKey()) {
82
+ val key = keyIterator.nextKey()
83
+ customAttributes[key] = attr.getString(key) ?: ""
84
+ }
85
+ Log.d(LOG_TAG, "customAttributes $customAttributes")
86
+ }
87
+ }
88
+
89
+ paywallLaunchContext = PaywallLaunchContext(productGroups.toList(), customAttributes)
90
+ }
91
+
38
92
  if (theActivity != null) {
39
93
  reactApplicationContext.runOnUiQueueThread {
94
+ val paywallActionCallback = {
95
+ campaignId: String,
96
+ campaignName: String?,
97
+ campaignType: String?,
98
+ campaignLabel: String?,
99
+ campaignUrl: String?,
100
+ paywallId: String,
101
+ paywallName: String?,
102
+ segmentId: String?,
103
+ externalSegmentId: String?,
104
+ action: NamiPaywallAction,
105
+ sku: NamiSKU?,
106
+ purchaseError: String?,
107
+ purchases: List<NamiPurchase>?,
108
+ deeplinkUrl: String? ->
109
+ handlePaywallCallback(
110
+ campaignId,
111
+ campaignName,
112
+ campaignType,
113
+ campaignLabel,
114
+ campaignUrl,
115
+ paywallId,
116
+ paywallName,
117
+ segmentId,
118
+ externalSegmentId,
119
+ action,
120
+ sku,
121
+ purchaseError,
122
+ purchases,
123
+ deeplinkUrl,
124
+ actionCallback)
125
+ }
126
+
40
127
  if (label != null) {
41
128
  NamiCampaignManager.launch(
42
129
  theActivity,
43
130
  label,
44
- paywallActionCallback = { campaignId, campaignLabel, paywallId, action, sku, purchaseError, purchases ->
45
- handlePaywallCallback(campaignId, campaignLabel, paywallId, action, sku, purchaseError, purchases, actionCallback)
46
- },
131
+ paywallActionCallback = paywallActionCallback,
132
+ paywallLaunchContext,
47
133
  ) { result -> handleResult(result, resultCallback) }
48
134
  } else {
49
135
  NamiCampaignManager.launch(
50
136
  theActivity,
51
- paywallActionCallback = { campaignId, campaignLabel, paywallId, action, sku, purchaseError, purchases ->
52
- handlePaywallCallback(campaignId, campaignLabel, paywallId, action, sku, purchaseError, purchases, actionCallback)
53
- },
137
+ paywallActionCallback = paywallActionCallback,
54
138
  ) { result -> handleResult(result, resultCallback) }
55
139
  }
56
140
  }
@@ -58,26 +142,67 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
58
142
 
59
143
  }
60
144
 
61
- private fun handlePaywallCallback(campaignId: String, campaignLabel: String?, paywallId: String, action: NamiPaywallAction, sku: NamiSKU?, purchaseError: String?, purchases: List<NamiPurchase>?, actionCallback: Callback) {
145
+ private fun handlePaywallCallback(
146
+ campaignId: String,
147
+ campaignName: String?,
148
+ campaignType: String?,
149
+ campaignLabel: String?,
150
+ campaignUrl: String?,
151
+ paywallId: String,
152
+ paywallName: String?,
153
+ segmentId: String?,
154
+ externalSegmentId: String?,
155
+ action: NamiPaywallAction,
156
+ sku: NamiSKU?,
157
+ purchaseError: String?,
158
+ purchases: List<NamiPurchase>?,
159
+ deeplinkUrl: String?,
160
+ actionCallback: Callback
161
+ ) {
62
162
  val actionString = action.toString()
63
- val skuString = sku?.skuId.orEmpty()
64
- val purchasesArray: WritableArray = WritableNativeArray()
65
- if (purchases != null) {
66
- for (purchase in purchases) {
67
- purchasesArray.pushMap(purchase.toPurchaseDict())
163
+ val skuString = sku?.skuId ?: ""
164
+
165
+ val purchasesArray = createPurchaseArray(purchases)
166
+
167
+ val resultMap = Arguments.createMap().apply {
168
+ putString(CAMPAIGN_ID, campaignId)
169
+ putString(CAMPAIGN_LABEL, campaignLabel ?: "")
170
+ putString(PAYWALL_ID, paywallId)
171
+ putString(ACTION, actionString)
172
+ putString(SKU_ID, skuString)
173
+ putString(PURCHASE_ERROR, purchaseError ?: "")
174
+ putArray(PURCHASES, purchasesArray)
175
+ putString(CAMPAIGN_NAME, campaignName ?: "")
176
+ putString(CAMPAIGN_TYPE, campaignType ?: "")
177
+ putString(CAMPAIGN_URL, campaignUrl ?: "")
178
+ putString(PAYWALL_NAME, paywallName ?: "")
179
+ putString(SEGMENT_ID, segmentId ?: "")
180
+ putString(EXTERNAL_SEGMENT_ID, externalSegmentId ?: "")
181
+ putString(DEEP_LINK_URL, deeplinkUrl ?: "")
182
+ }
183
+
184
+ emitEvent(_RESULT_CAMPAIGN, resultMap)
185
+ }
186
+
187
+ private fun createPurchaseArray(purchases: List<NamiPurchase>?): WritableArray {
188
+ return WritableNativeArray().apply {
189
+ purchases?.forEach { purchase ->
190
+ try {
191
+ pushMap(purchase.toPurchaseDict())
192
+ } catch (e: Exception) {
193
+ Log.e(LOG_TAG, "Error while converting data in createPurchaseArray to a Map", e)
194
+ }
68
195
  }
69
196
  }
70
- val resultMap = Arguments.createMap()
71
- resultMap.putString("campaignId", campaignId)
72
- resultMap.putString("campaignLabel", campaignLabel)
73
- resultMap.putString("paywallId", paywallId)
74
- resultMap.putString("action", actionString)
75
- resultMap.putString("skuId", skuString)
76
- resultMap.putString("purchaseError", purchaseError)
77
- resultMap.putArray("purchases", purchasesArray)
78
- reactApplicationContext
79
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
80
- .emit("ResultCampaign", resultMap)
197
+ }
198
+
199
+ private fun emitEvent(event: String, map: WritableMap) {
200
+ val emitter = reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
201
+ if (emitter is DeviceEventManagerModule.RCTDeviceEventEmitter) {
202
+ emitter.emit(event, map)
203
+ } else {
204
+ Log.w(LOG_TAG, "Cannot emit $event event: RCTDeviceEventEmitter instance is null")
205
+ }
81
206
  }
82
207
 
83
208
  private fun handleResult(result: LaunchCampaignResult, resultCallback: Callback) {
@@ -55,6 +55,17 @@ class NamiCustomerManagerBridgeModule(reactContext: ReactApplicationContext) :
55
55
  NamiCustomerManager.setCustomerDataPlatformId(cdpId)
56
56
  }
57
57
 
58
+ @ReactMethod
59
+ fun setAnonymousMode(anonymousMode: Boolean) {
60
+ NamiCustomerManager.setAnonymousMode(anonymousMode)
61
+ }
62
+
63
+ @ReactMethod
64
+ fun inAnonymousMode(promise: Promise) {
65
+ val anonymousMode = NamiCustomerManager.inAnonymousMode()
66
+ promise.resolve(anonymousMode)
67
+ }
68
+
58
69
  @ReactMethod
59
70
  fun journeyState(promise: Promise) {
60
71
  val journeyState = NamiCustomerManager.journeyState()
package/index.d.ts CHANGED
@@ -1,20 +1,20 @@
1
- export { Nami, NamiConfiguration, NamiLanguageCodes } from "./src/Nami";
2
- export { NamiMLManager } from "./src/NamiMLManager";
1
+ export {Nami, NamiConfiguration, NamiLanguageCodes} from './src/Nami';
2
+ export {NamiMLManager} from './src/NamiMLManager';
3
3
  export {
4
4
  NamiCampaignManager,
5
5
  NamiCampaign,
6
- NamiCampaignRuleType,
6
+ NamiCampaignRule,
7
7
  LaunchCampaignError,
8
- } from "./src/NamiCampaignManager";
8
+ } from './src/NamiCampaignManager';
9
9
  export {
10
10
  NamiCustomerManager,
11
11
  CustomerJourneyState,
12
12
  AccountStateAction,
13
- } from "./src/NamiCustomerManager";
13
+ } from './src/NamiCustomerManager';
14
14
  export {
15
15
  NamiEntitlementManager,
16
16
  NamiEntitlement,
17
- } from "./src/NamiEntitlementManager";
18
- export { NamiPurchaseManager, NamiPurchase } from "./src/NamiPurchaseManager";
19
- export { NamiPaywallManager } from "./src/NamiPaywallManager";
20
- export { NamiSKU } from "./src/types";
17
+ } from './src/NamiEntitlementManager';
18
+ export {NamiPurchaseManager, NamiPurchase} from './src/NamiPurchaseManager';
19
+ export {NamiPaywallManager} from './src/NamiPaywallManager';
20
+ export {NamiSKU} from './src/types';
package/ios/Nami.m CHANGED
@@ -52,7 +52,7 @@ RCT_EXPORT_METHOD(configure: (NSDictionary *)configDict completion: (RCTResponse
52
52
  }
53
53
 
54
54
  // Start commands with header iformation for Nami to let them know this is a React client.
55
- NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.0.13"]];
55
+ NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.0.15"]];
56
56
 
57
57
  // Add additional namiCommands app may have sent in.
58
58
  NSObject *appCommandStrings = configDict[@"namiCommands"];
@@ -9,7 +9,7 @@
9
9
 
10
10
  @interface RCT_EXTERN_MODULE(RNNamiCampaignManager, NSObject)
11
11
 
12
- RCT_EXTERN_METHOD(launch:(nullable NSString *)label completion:(RCTResponseSenderBlock)callback paywallCompletion:(RCTResponseSenderBlock)cpaywallCallback)
12
+ RCT_EXTERN_METHOD(launch:(nullable NSString *)label context:(nullable NSDictionary *)context completion:(RCTResponseSenderBlock)callback paywallCompletion:(RCTResponseSenderBlock)cpaywallCallback)
13
13
 
14
14
  RCT_EXTERN_METHOD(allCampaigns:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
15
15
 
@@ -34,11 +34,28 @@ class RNNamiCampaignManager: RCTEventEmitter {
34
34
  return NSDictionary(dictionary: dictionary.compactMapValues { $0 })
35
35
  }
36
36
 
37
- @objc(launch:completion:paywallCompletion:)
38
- func launch(label: String?, callback: @escaping RCTResponseSenderBlock, paywallCallback _: @escaping RCTResponseSenderBlock) {
39
- NamiCampaignManager.launch(label: label, launchHandler: { success, error in
37
+ @objc(launch:context:completion:paywallCompletion:)
38
+ func launch(label: String?, context: NSDictionary?, callback: @escaping RCTResponseSenderBlock, paywallCallback _: @escaping RCTResponseSenderBlock) {
39
+ var paywallLaunchContext: PaywallLaunchContext?
40
+
41
+ var productGroups: [String]?
42
+ var customAttributes: [String: Any]?
43
+ if let context = context {
44
+ if let contextProductGroups = context["productGroups"] as? [String] {
45
+ productGroups = contextProductGroups
46
+ }
47
+ if let contextCustomAttributes = context["customAttributes"] as? [String: Any] {
48
+ customAttributes = contextCustomAttributes
49
+ }
50
+ }
51
+
52
+ if productGroups != nil || customAttributes != nil {
53
+ paywallLaunchContext = PaywallLaunchContext(productGroups: productGroups, customAttributes: customAttributes)
54
+ }
55
+
56
+ NamiCampaignManager.launch(label: label, context: paywallLaunchContext, launchHandler: { success, error in
40
57
  callback([success, error?._code as Any])
41
- }, paywallActionHandler: { campaignId, campaignLabel, paywallId, action, sku, purchaseError, purchases in
58
+ }, paywallActionHandler: { campaignId, campaignName, campaignType, campaignLabel, campaignUrl, paywallId, paywallName, segmentId, externalSegmentId, _, action, sku, purchaseError, purchases, deeplinkUrl in
42
59
  let actionString: String
43
60
  switch action {
44
61
  case .show_paywall:
@@ -65,6 +82,8 @@ class RNNamiCampaignManager: RCTEventEmitter {
65
82
  actionString = "PURCHASE_CANCELLED"
66
83
  case .purchase_unknown:
67
84
  actionString = "PURCHASE_UNKNOWN"
85
+ case .deeplink:
86
+ actionString = "DEEPLINK"
68
87
  @unknown default:
69
88
  actionString = "PURCHASE_UNKNOWN"
70
89
  }
@@ -74,12 +93,19 @@ class RNNamiCampaignManager: RCTEventEmitter {
74
93
  let dictionaries = purchases.map { purchase in RNNamiPurchaseManager.purchaseToPurchaseDict(purchase) }
75
94
  let payload: [String: Any?] = [
76
95
  "campaignId": campaignId,
96
+ "campaignName": campaignName,
97
+ "campaignType": campaignType,
77
98
  "campaignLabel": campaignLabel,
99
+ "campaignUrl": campaignUrl,
78
100
  "paywallId": paywallId,
101
+ "paywallName": paywallName,
102
+ "segmentId": segmentId,
103
+ "externalSegmentId": externalSegmentId,
79
104
  "action": actionString,
80
105
  "skuId": skuId,
81
106
  "purchaseError": errorSting,
82
107
  "purchases": dictionaries,
108
+ "deeplinkUrl": deeplinkUrl,
83
109
  ]
84
110
  RNNamiCampaignManager.shared?.sendEvent(withName: "ResultCampaign", body: payload)
85
111
  })
@@ -21,6 +21,10 @@ RCT_EXTERN_METHOD(setCustomerDataPlatformId:(NSString *)platformId)
21
21
 
22
22
  RCT_EXTERN_METHOD(clearCustomerDataPlatformId)
23
23
 
24
+ RCT_EXTERN_METHOD(setAnonymousMode:(BOOL *)anonymousMode)
25
+
26
+ RCT_EXTERN_METHOD(inAnonymousMode:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
27
+
24
28
  RCT_EXTERN_METHOD(journeyState:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
25
29
 
26
30
  RCT_EXTERN_METHOD(isLoggedIn:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
@@ -66,6 +66,17 @@ class RNNamiCustomerManager: RCTEventEmitter {
66
66
  NamiCustomerManager.clearCustomerDataPlatformId()
67
67
  }
68
68
 
69
+ @objc(setAnonymousMode:)
70
+ func setAnonymousMode(anonymousMode: Bool) {
71
+ NamiCustomerManager.setAnonymousMode(anonymousMode)
72
+ }
73
+
74
+ @objc(inAnonymousMode:rejecter:)
75
+ func inAnonymousMode(resolve: @escaping RCTPromiseResolveBlock, reject _: @escaping RCTPromiseRejectBlock) {
76
+ let inAnonymousMode: Bool = NamiCustomerManager.inAnonymousMode()
77
+ resolve(inAnonymousMode)
78
+ }
79
+
69
80
  @objc(journeyState:rejecter:)
70
81
  func journeyState(resolve: @escaping RCTPromiseResolveBlock, reject _: @escaping RCTPromiseRejectBlock) {
71
82
  if let journeyState = NamiCustomerManager.journeyState() {
@@ -137,6 +148,14 @@ class RNNamiCustomerManager: RCTEventEmitter {
137
148
  actionString = "vendor_id_set"
138
149
  case .vendor_id_cleared:
139
150
  actionString = "vendor_id_cleared"
151
+ case .nami_device_id_set:
152
+ actionString = "nami_device_id_set"
153
+ case .nami_device_id_cleared:
154
+ actionString = "nami_device_id_cleared"
155
+ case .anonymous_mode_on:
156
+ actionString = "anonymous_mode_on"
157
+ case .anonymous_mode_off:
158
+ actionString = "anonymous_mode_off"
140
159
  @unknown default:
141
160
  actionString = "unknown"
142
161
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nami-sdk",
3
- "version": "3.0.13",
3
+ "version": "3.0.15",
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": {
@@ -20,7 +20,7 @@ Pod::Spec.new do |s|
20
20
  s.source_files = "ios/**/*.{h,m,swift}"
21
21
  s.requires_arc = true
22
22
 
23
- s.dependency 'Nami', '3.0.15'
23
+ s.dependency 'Nami', '3.0.18'
24
24
  s.dependency 'React'
25
25
 
26
26
  end
@@ -1,27 +1,35 @@
1
- import { EmitterSubscription } from "react-native";
2
- import { NamiPurchase } from "./NamiPurchaseManager";
3
- import { NamiPaywallAction } from "./NamiPaywallManager";
1
+ import {EmitterSubscription} from 'react-native';
2
+ import {NamiPurchase} from './NamiPurchaseManager';
3
+ import {NamiPaywallAction} from './NamiPaywallManager';
4
4
 
5
5
  export const NamiCampaignManager: {
6
6
  allCampaigns: () => Promise<Array<NamiCampaign>>;
7
7
  isCampaignAvailable: (label?: string) => boolean;
8
8
  launch: (
9
9
  label?: string,
10
+ context?: PaywallLaunchContext,
10
11
  resultCallback?: (success: boolean, error?: LaunchCampaignError) => void,
11
12
  actionCallback?: (
13
+ campaignId: string,
14
+ paywallId: string,
12
15
  action: NamiPaywallAction,
16
+ campaignName?: string,
17
+ campaignType?: string,
18
+ campaignLabel?: string,
19
+ campaignUrl?: string,
20
+ paywallName?: string,
21
+ segmentId?: string,
22
+ externalSegmentId?: string,
23
+ deeplinkUrl?: string,
13
24
  skuId?: string,
14
25
  purchaseError?: string,
15
26
  purchases?: NamiPurchase[],
16
- campaignId?: string,
17
- campaignLabel?: string,
18
- paywallId?: string
19
- ) => void
27
+ ) => void,
20
28
  ) => void;
21
29
  refresh: () => void;
22
30
  registerAvailableCampaignsHandler: (
23
- callback: (availableCampaigns: NamiCampaign[]) => void
24
- ) => EmitterSubscription["remove"];
31
+ callback: (availableCampaigns: NamiCampaign[]) => void,
32
+ ) => EmitterSubscription['remove'];
25
33
  };
26
34
 
27
35
  export type NamiCampaign = {
@@ -29,14 +37,15 @@ export type NamiCampaign = {
29
37
  rule: string;
30
38
  segment: string;
31
39
  paywall: string;
32
- type: NamiCampaignRuleType;
40
+ type: NamiCampaignRule;
33
41
  value?: string | null;
34
42
  };
35
43
 
36
- export enum NamiCampaignRuleType {
37
- DEFAULT = "default",
38
- LABEL = "label",
39
- UNKNOWN = "unknown",
44
+ export enum NamiCampaignRule {
45
+ DEFAULT = 'default',
46
+ LABEL = 'label',
47
+ UNKNOWN = 'unknown',
48
+ URL = 'url',
40
49
  }
41
50
 
42
51
  export enum LaunchCampaignError {
@@ -48,10 +57,17 @@ export enum LaunchCampaignError {
48
57
  }
49
58
 
50
59
  export enum LaunchCampaignResultAction {
51
- FAILURE = "FAILURE",
52
- SUCCESS = "SUCCESS",
60
+ FAILURE = 'FAILURE',
61
+ SUCCESS = 'SUCCESS',
53
62
  }
54
63
 
55
64
  export type FailureResultObject = {
56
65
  error: string;
57
66
  };
67
+
68
+ export type PaywallLaunchContext = {
69
+ productGroups?: string[];
70
+ customAttributes?: {
71
+ [key: string]: string;
72
+ };
73
+ };
@@ -1,28 +1,36 @@
1
- import { NativeModules, NativeEventEmitter } from "react-native";
1
+ import {NativeModules, NativeEventEmitter} from 'react-native';
2
2
 
3
- export const { RNNamiCampaignManager } = NativeModules;
3
+ export const {RNNamiCampaignManager} = NativeModules;
4
4
 
5
5
  export const NamiCampaignManager = {
6
6
  launchSubscription: undefined,
7
7
  emitter: new NativeEventEmitter(RNNamiCampaignManager),
8
8
  ...RNNamiCampaignManager,
9
- launch(label, resultCallback, actionCallback) {
9
+ launch(label, context, resultCallback, actionCallback) {
10
10
  this.launchSubscription?.remove();
11
11
  this.launchSubscription = this.emitter.addListener(
12
- "ResultCampaign",
13
- (body) => {
14
- var action = body.action;
12
+ 'ResultCampaign',
13
+ body => {
14
+ body.action = body.action.startsWith('NAMI_')
15
+ ? body.action.substring(5, body.action.length)
16
+ : body.action;
15
17
 
16
- if (action.startsWith("NAMI_")) {
17
- action = action.substring(5, action.length);
18
- }
19
-
20
- var skuId = body.skuId;
21
- var purchaseError = body.purchaseError;
22
- var purchases = body.purchases;
23
- var campaignId = body.campaignId;
24
- var campaignLabel = body.campaignLabel;
25
- var paywallId = body.paywallId;
18
+ const {
19
+ action,
20
+ skuId,
21
+ purchaseError,
22
+ purchases,
23
+ campaignId,
24
+ campaignLabel,
25
+ paywallId,
26
+ campaignName,
27
+ campaignType,
28
+ campaignUrl,
29
+ segmentId,
30
+ externalSegmentId,
31
+ paywallName,
32
+ deeplinkUrl,
33
+ } = body;
26
34
  actionCallback(
27
35
  action,
28
36
  skuId,
@@ -30,23 +38,32 @@ export const NamiCampaignManager = {
30
38
  purchases,
31
39
  campaignId,
32
40
  campaignLabel,
33
- paywallId
41
+ paywallId,
42
+ campaignName,
43
+ campaignType,
44
+ campaignUrl,
45
+ segmentId,
46
+ externalSegmentId,
47
+ paywallName,
48
+ deeplinkUrl,
34
49
  );
35
- }
50
+ },
36
51
  );
52
+
37
53
  RNNamiCampaignManager.launch(
38
54
  label ?? null,
55
+ context ?? null,
39
56
  resultCallback ?? (() => {}),
40
- actionCallback ?? (() => {})
57
+ actionCallback ?? (() => {}),
41
58
  );
42
59
  },
43
- isCampaignAvailable: (label) => {
60
+ isCampaignAvailable: label => {
44
61
  return RNNamiCampaignManager.isCampaignAvailable(label ?? null);
45
62
  },
46
63
  registerAvailableCampaignsHandler(callback) {
47
64
  const subscription = this.emitter.addListener(
48
- "AvailableCampaignsChanged",
49
- callback
65
+ 'AvailableCampaignsChanged',
66
+ callback,
50
67
  );
51
68
  RNNamiCampaignManager.registerAvailableCampaignsHandler();
52
69
  return subscription.remove;
@@ -26,6 +26,8 @@ export const NamiCustomerManager: {
26
26
  ) => EmitterSubscription["remove"];
27
27
  clearCustomerDataPlatformId: () => void;
28
28
  setCustomerDataPlatformId: (platformId: string) => void;
29
+ setAnonymousMode: (anonymousMode: boolean) => void;
30
+ inAnonymousMode: () => Promise<boolean>;
29
31
  };
30
32
 
31
33
  export type CustomerJourneyState = {
@@ -38,4 +40,4 @@ export type CustomerJourneyState = {
38
40
  inAccountHold: boolean;
39
41
  };
40
42
 
41
- export type AccountStateAction = "login" | "logout";
43
+ export type AccountStateAction = "login" | "logout" | "advertising_id_set" | "vendor_id_set" | "customer_data_platform_id_set" | "nami_device_id_set" | "advertising_id_cleared" | "vendor_id_cleared" | "customer_data_platform_id_cleared" | "nami_device_id_cleared" | "anonymous_mode_on" | "anonymous_mode_off";
@@ -60,4 +60,5 @@ export enum NamiPaywallAction {
60
60
  PURCHASE_PENDING = "PURCHASE_PENDING",
61
61
  PURCHASE_UNKNOWN = "PURCHASE_UNKNOWN",
62
62
  PURCHASE_DEFERRED = "PURCHASE_DEFERRED",
63
+ DEEPLINK = "DEEPLINK",
63
64
  }