react-native-nami-sdk 3.0.30 → 3.0.32
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 +1 -1
- package/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt +18 -30
- package/ios/Nami.m +1 -1
- package/ios/NamiCampaignManagerBridge.swift +2 -0
- package/ios/NamiPaywallManagerBridge.m +2 -0
- package/ios/NamiPaywallManagerBridge.swift +8 -1
- package/package.json +1 -1
- package/react-native-nami-sdk.podspec +1 -1
- package/src/NamiPaywallManager.d.ts +3 -0
- package/src/NamiPaywallManager.ts +23 -8
package/android/build.gradle
CHANGED
|
@@ -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
|
-
compileOnly "com.namiml:sdk-amazon:3.1.
|
|
87
|
+
compileOnly "com.namiml:sdk-amazon:3.1.8"
|
|
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.
|
|
118
|
+
val settingsList = mutableListOf("extendedClientInfo:react-native:3.0.32")
|
|
119
119
|
namiCommandsReact?.toArrayList()?.filterIsInstance<String>()?.let { commandsFromReact ->
|
|
120
120
|
settingsList.addAll(commandsFromReact)
|
|
121
121
|
}
|
|
@@ -25,7 +25,7 @@ class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
25
25
|
fun buySkuComplete(dict: ReadableMap, storeType: String) {
|
|
26
26
|
var product: ReadableMap? = null
|
|
27
27
|
var productId: String? = null
|
|
28
|
-
var
|
|
28
|
+
var skuRefId: String? = null
|
|
29
29
|
var typeString: String? = null
|
|
30
30
|
var purchaseSourceString: String? = null
|
|
31
31
|
var expiresDateInt: Int? = null
|
|
@@ -54,7 +54,7 @@ class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
if (product.hasKey("skuId")) {
|
|
57
|
-
|
|
57
|
+
skuRefId = product.getString("skuId")
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
if (product.hasKey("type")) {
|
|
@@ -75,21 +75,6 @@ class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
75
75
|
purchaseDate = Date(purchaseDateInt * 1000L)
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
skuType = when (typeString) {
|
|
79
|
-
"UNKNOWN" -> {
|
|
80
|
-
NamiSKUType.UNKNOWN
|
|
81
|
-
}
|
|
82
|
-
"SUBSCRIPTION" -> {
|
|
83
|
-
NamiSKUType.SUBSCRIPTION
|
|
84
|
-
}
|
|
85
|
-
"ONE_TIME_PURCHASE" -> {
|
|
86
|
-
NamiSKUType.ONE_TIME_PURCHASE
|
|
87
|
-
}
|
|
88
|
-
else -> {
|
|
89
|
-
NamiSKUType.UNKNOWN
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
78
|
val purchaseSource = when (purchaseSourceString) {
|
|
94
79
|
"CAMPAIGN" -> {
|
|
95
80
|
NamiPurchaseSource.CAMPAIGN
|
|
@@ -105,19 +90,10 @@ class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
105
90
|
}
|
|
106
91
|
}
|
|
107
92
|
|
|
108
|
-
if (productId != null &&
|
|
109
|
-
val namiSku = NamiSKU(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
amazonProduct = null,
|
|
113
|
-
id = productId,
|
|
114
|
-
type = skuType,
|
|
115
|
-
name = "",
|
|
116
|
-
featured = false,
|
|
117
|
-
rawDisplayText = null,
|
|
118
|
-
rawSubDisplayText = null,
|
|
119
|
-
entitlements = emptyList(),
|
|
120
|
-
variables = null,
|
|
93
|
+
if (productId != null && skuRefId != null) {
|
|
94
|
+
val namiSku = NamiSKU.create(
|
|
95
|
+
skuRefId = skuRefId,
|
|
96
|
+
skuId = productId,
|
|
121
97
|
)
|
|
122
98
|
var purchaseSuccess: NamiPurchaseSuccess? = null
|
|
123
99
|
|
|
@@ -235,6 +211,18 @@ class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
235
211
|
}
|
|
236
212
|
}
|
|
237
213
|
|
|
214
|
+
@ReactMethod
|
|
215
|
+
fun registerDeeplinkActionHandler() {
|
|
216
|
+
NamiPaywallManager.registerDeepLinkHandler { activity , url ->
|
|
217
|
+
latestPaywallActivity = activity
|
|
218
|
+
reactApplicationContext
|
|
219
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
220
|
+
.emit("PaywallDeeplinkAction", url)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
|
|
238
226
|
@ReactMethod
|
|
239
227
|
fun show() {
|
|
240
228
|
// Do nothing on Android side
|
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.
|
|
55
|
+
NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.0.32"]];
|
|
56
56
|
|
|
57
57
|
// Add additional namiCommands app may have sent in.
|
|
58
58
|
NSObject *appCommandStrings = configDict[@"namiCommands"];
|
|
@@ -63,6 +63,8 @@ class RNNamiCampaignManager: RCTEventEmitter {
|
|
|
63
63
|
actionString = "PURCHASE_SELECTED_SKU"
|
|
64
64
|
case .purchase_success:
|
|
65
65
|
actionString = "PURCHASE_SUCCESS"
|
|
66
|
+
case .purchase_pending:
|
|
67
|
+
actionString = "PURCHASE_PENDING"
|
|
66
68
|
case .purchase_deferred:
|
|
67
69
|
actionString = "PURCHASE_DEFERRED"
|
|
68
70
|
case .purchase_failed:
|
|
@@ -19,7 +19,7 @@ class RNNamiPaywallManager: RCTEventEmitter {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
override func supportedEvents() -> [String]! {
|
|
22
|
-
return ["RegisterBuySKU", "PaywallCloseRequested", "PaywallSignInRequested", "PaywallRestoreRequested"]
|
|
22
|
+
return ["RegisterBuySKU", "PaywallCloseRequested", "PaywallSignInRequested", "PaywallRestoreRequested", "PaywallDeeplinkAction"]
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
@objc(buySkuComplete:)
|
|
@@ -111,6 +111,13 @@ class RNNamiPaywallManager: RCTEventEmitter {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
@objc(registerDeeplinkActionHandler)
|
|
115
|
+
func registerDeeplinkActionHandler() {
|
|
116
|
+
NamiPaywallManager.registerDeeplinkActionHandler { url in
|
|
117
|
+
RNNamiPaywallManager.shared?.sendEvent(withName: "PaywallDeeplinkAction", body: url)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
114
121
|
@objc(dismiss:)
|
|
115
122
|
func dismiss(animated: Bool) {
|
|
116
123
|
NamiPaywallManager.dismiss(animated: animated) {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nami-sdk",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.32",
|
|
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.ts",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -18,6 +18,9 @@ export const NamiPaywallManager: {
|
|
|
18
18
|
registerRestoreHandler: (
|
|
19
19
|
callback: () => void,
|
|
20
20
|
) => EmitterSubscription['remove'];
|
|
21
|
+
registerDeeplinkActionHandler: (
|
|
22
|
+
callback: (url: string) => void,
|
|
23
|
+
) => EmitterSubscription['remove'];
|
|
21
24
|
show: () => void;
|
|
22
25
|
hide: () => void;
|
|
23
26
|
buySkuCancel: () => void;
|
|
@@ -15,6 +15,7 @@ export enum NamiPaywallManagerEvents {
|
|
|
15
15
|
PaywallCloseRequested = 'PaywallCloseRequested',
|
|
16
16
|
PaywallSignInRequested = 'PaywallSignInRequested',
|
|
17
17
|
PaywallRestoreRequested = 'PaywallRestoreRequested',
|
|
18
|
+
PaywallDeeplinkAction = 'PaywallDeeplinkAction',
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export enum ServicesEnum {
|
|
@@ -29,6 +30,7 @@ export interface INamiPaywallManager {
|
|
|
29
30
|
buySkuCompleteGooglePlay: (
|
|
30
31
|
purchaseSuccess: NamiPurchaseSuccessGooglePlay,
|
|
31
32
|
) => void;
|
|
33
|
+
buySkuCancel: () => void;
|
|
32
34
|
registerBuySkuHandler: (
|
|
33
35
|
callback: (sku: NamiSKU) => void,
|
|
34
36
|
) => EmitterSubscription['remove'];
|
|
@@ -39,6 +41,9 @@ export interface INamiPaywallManager {
|
|
|
39
41
|
registerRestoreHandler: (
|
|
40
42
|
callback: () => void,
|
|
41
43
|
) => EmitterSubscription['remove'];
|
|
44
|
+
registerDeeplinkActionHandler: (
|
|
45
|
+
callback: (url: string) => void,
|
|
46
|
+
) => EmitterSubscription['remove'];
|
|
42
47
|
dismiss: (animated?: boolean) => void;
|
|
43
48
|
show: () => void;
|
|
44
49
|
hide: () => void;
|
|
@@ -69,8 +74,7 @@ export const NamiPaywallManager: INamiPaywallManager = {
|
|
|
69
74
|
RNNamiPaywallManager.buySkuCancel();
|
|
70
75
|
},
|
|
71
76
|
registerBuySkuHandler: (callback: (sku: NamiSKU) => void) => {
|
|
72
|
-
let subscription
|
|
73
|
-
subscription = NamiPaywallManager.paywallEmitter.addListener(
|
|
77
|
+
let subscription = NamiPaywallManager.paywallEmitter.addListener(
|
|
74
78
|
NamiPaywallManagerEvents.RegisterBuySKU,
|
|
75
79
|
sku => {
|
|
76
80
|
callback(sku);
|
|
@@ -84,8 +88,7 @@ export const NamiPaywallManager: INamiPaywallManager = {
|
|
|
84
88
|
};
|
|
85
89
|
},
|
|
86
90
|
registerCloseHandler: (callback: (body: any) => void) => {
|
|
87
|
-
let subscription
|
|
88
|
-
subscription = NamiPaywallManager.paywallEmitter.addListener(
|
|
91
|
+
let subscription = NamiPaywallManager.paywallEmitter.addListener(
|
|
89
92
|
NamiPaywallManagerEvents.PaywallCloseRequested,
|
|
90
93
|
body => {
|
|
91
94
|
callback(body);
|
|
@@ -99,8 +102,7 @@ export const NamiPaywallManager: INamiPaywallManager = {
|
|
|
99
102
|
};
|
|
100
103
|
},
|
|
101
104
|
registerSignInHandler(callback) {
|
|
102
|
-
let subscription
|
|
103
|
-
subscription = NamiPaywallManager.paywallEmitter.addListener(
|
|
105
|
+
let subscription = NamiPaywallManager.paywallEmitter.addListener(
|
|
104
106
|
NamiPaywallManagerEvents.PaywallSignInRequested,
|
|
105
107
|
() => {
|
|
106
108
|
callback();
|
|
@@ -115,8 +117,7 @@ export const NamiPaywallManager: INamiPaywallManager = {
|
|
|
115
117
|
};
|
|
116
118
|
},
|
|
117
119
|
registerRestoreHandler(callback) {
|
|
118
|
-
let subscription
|
|
119
|
-
subscription = NamiPaywallManager.paywallEmitter.addListener(
|
|
120
|
+
let subscription = NamiPaywallManager.paywallEmitter.addListener(
|
|
120
121
|
NamiPaywallManagerEvents.PaywallRestoreRequested,
|
|
121
122
|
() => {
|
|
122
123
|
callback();
|
|
@@ -129,6 +130,20 @@ export const NamiPaywallManager: INamiPaywallManager = {
|
|
|
129
130
|
}
|
|
130
131
|
};
|
|
131
132
|
},
|
|
133
|
+
registerDeeplinkActionHandler: (callback: (url: string) => void) => {
|
|
134
|
+
let subscription = NamiPaywallManager.paywallEmitter.addListener(
|
|
135
|
+
NamiPaywallManagerEvents.PaywallDeeplinkAction,
|
|
136
|
+
url => {
|
|
137
|
+
callback(url);
|
|
138
|
+
},
|
|
139
|
+
);
|
|
140
|
+
RNNamiPaywallManager.registerDeeplinkActionHandler();
|
|
141
|
+
return () => {
|
|
142
|
+
if (subscription) {
|
|
143
|
+
subscription.remove();
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
},
|
|
132
147
|
dismiss: (animated?: boolean) => {
|
|
133
148
|
RNNamiPaywallManager.dismiss(animated ?? true);
|
|
134
149
|
},
|