react-native-nami-sdk 3.4.1 → 3.4.2-dev.202606022148
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 +2 -2
- package/android/src/main/java/com/namiml/reactnative/{NamiFlowManagerBridge.kt → NamiFlowManagerBridgeModule.kt} +6 -1
- package/dist/specs/NativeNamiCampaignManager.d.ts +1 -1
- package/dist/specs/NativeNamiPurchaseManager.d.ts +1 -0
- package/dist/src/types.d.ts +11 -1
- package/dist/src/version.d.ts +1 -1
- package/ios/NamiPurchaseManagerBridge.swift +1 -0
- package/package.json +2 -2
- package/react-native-nami-sdk.podspec +1 -1
- package/specs/NativeNamiCampaignManager.ts +1 -1
- package/specs/NativeNamiPurchaseManager.ts +1 -0
- package/src/__tests__/transformers.test.ts +24 -3
- package/src/types.ts +12 -1
- package/src/version.ts +1 -1
package/android/build.gradle
CHANGED
|
@@ -85,8 +85,8 @@ dependencies {
|
|
|
85
85
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
86
86
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
|
87
87
|
|
|
88
|
-
playImplementation "com.namiml:sdk-android:3.4.
|
|
89
|
-
amazonImplementation "com.namiml:sdk-amazon:3.4.
|
|
88
|
+
playImplementation "com.namiml:sdk-android:3.4.2-dev.202606022148"
|
|
89
|
+
amazonImplementation "com.namiml:sdk-amazon:3.4.2-dev.202606022148"
|
|
90
90
|
|
|
91
91
|
implementation "com.facebook.react:react-native:+" // From node_modules
|
|
92
92
|
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.0.4"
|
|
@@ -3,7 +3,12 @@ package com.namiml.reactnative
|
|
|
3
3
|
import android.os.Handler
|
|
4
4
|
import android.os.Looper
|
|
5
5
|
import android.util.Log
|
|
6
|
-
import com.facebook.react.bridge
|
|
6
|
+
import com.facebook.react.bridge.Arguments
|
|
7
|
+
import com.facebook.react.bridge.Promise
|
|
8
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
9
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
10
|
+
import com.facebook.react.bridge.ReactMethod
|
|
11
|
+
import com.facebook.react.bridge.WritableMap
|
|
7
12
|
import com.facebook.react.module.annotations.ReactModule
|
|
8
13
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
9
14
|
import com.facebook.react.turbomodule.core.interfaces.TurboModule
|
|
@@ -3,7 +3,7 @@ export interface Spec extends TurboModule {
|
|
|
3
3
|
launch(label: string | null, withUrl: string | null, context: {
|
|
4
4
|
productGroups?: string[];
|
|
5
5
|
customAttributes?: {
|
|
6
|
-
[key: string]: string;
|
|
6
|
+
[key: string]: string | boolean | number;
|
|
7
7
|
};
|
|
8
8
|
customObject?: {
|
|
9
9
|
[key: string]: unknown;
|
package/dist/src/types.d.ts
CHANGED
|
@@ -92,10 +92,18 @@ export declare enum LaunchCampaignResultAction {
|
|
|
92
92
|
export type FailureResultObject = {
|
|
93
93
|
error: string;
|
|
94
94
|
};
|
|
95
|
+
/**
|
|
96
|
+
* Permitted value types for entries in {@link PaywallLaunchContext.customAttributes}.
|
|
97
|
+
*
|
|
98
|
+
* Both native primitives and their string equivalents are accepted; the underlying
|
|
99
|
+
* Apple/Android SDKs treat the two wire formats identically when evaluating
|
|
100
|
+
* targeting predicates.
|
|
101
|
+
*/
|
|
102
|
+
export type CustomAttributeValue = string | boolean | number;
|
|
95
103
|
export type PaywallLaunchContext = {
|
|
96
104
|
productGroups?: string[];
|
|
97
105
|
customAttributes: {
|
|
98
|
-
[key: string]:
|
|
106
|
+
[key: string]: CustomAttributeValue;
|
|
99
107
|
};
|
|
100
108
|
customObject?: {
|
|
101
109
|
[key: string]: unknown;
|
|
@@ -185,6 +193,7 @@ export type NamiPurchase = {
|
|
|
185
193
|
sku?: NamiSKU;
|
|
186
194
|
skuId: string;
|
|
187
195
|
transactionIdentifier?: string;
|
|
196
|
+
originalTransactionIdentifier?: string;
|
|
188
197
|
purchaseToken?: string;
|
|
189
198
|
expires?: Date;
|
|
190
199
|
purchaseInitiatedTimestamp: Date;
|
|
@@ -194,6 +203,7 @@ export type NamiPurchaseFromBridge = {
|
|
|
194
203
|
sku?: NamiSKU;
|
|
195
204
|
skuId: string;
|
|
196
205
|
transactionIdentifier?: string;
|
|
206
|
+
originalTransactionIdentifier?: string;
|
|
197
207
|
purchaseToken?: string;
|
|
198
208
|
expires?: number;
|
|
199
209
|
purchaseInitiatedTimestamp: number;
|
package/dist/src/version.d.ts
CHANGED
|
@@ -94,6 +94,7 @@ class RNNamiPurchaseManager: RCTEventEmitter {
|
|
|
94
94
|
var purchaseDict: [String: Any?] = [
|
|
95
95
|
"skuId": purchase.skuId,
|
|
96
96
|
"transactionIdentifier": purchase.transactionIdentifier,
|
|
97
|
+
"originalTransactionIdentifier": purchase.originalTransactionId,
|
|
97
98
|
"sku": skuDictionary,
|
|
98
99
|
"purchaseInitiatedTimestamp": purchase.purchaseInitiatedTimestamp.timeIntervalSince1970 * 1000,
|
|
99
100
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nami-sdk",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.2-dev.202606022148",
|
|
4
4
|
"description": "React Native SDK for Nami - No-code paywall and onboarding flows with A/B testing.",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
]
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"@namiml/expo-nami-iap": "3.4.
|
|
66
|
+
"@namiml/expo-nami-iap": "3.4.2-dev.202606022148",
|
|
67
67
|
"react": ">=18",
|
|
68
68
|
"react-native": ">=0.73"
|
|
69
69
|
},
|
|
@@ -7,7 +7,7 @@ export interface Spec extends TurboModule {
|
|
|
7
7
|
withUrl: string | null,
|
|
8
8
|
context: {
|
|
9
9
|
productGroups?: string[];
|
|
10
|
-
customAttributes?: { [key: string]: string };
|
|
10
|
+
customAttributes?: { [key: string]: string | boolean | number };
|
|
11
11
|
customObject?: { [key: string]: unknown };
|
|
12
12
|
} | null,
|
|
13
13
|
completion: (
|
|
@@ -14,6 +14,7 @@ export interface Spec extends TurboModule {
|
|
|
14
14
|
promoToken?: string;
|
|
15
15
|
};
|
|
16
16
|
transactionIdentifier?: string;
|
|
17
|
+
originalTransactionIdentifier?: string;
|
|
17
18
|
purchaseToken?: string;
|
|
18
19
|
expires?: number; // timestamp in milliseconds
|
|
19
20
|
purchaseInitiatedTimestamp: number; // timestamp in milliseconds
|
|
@@ -46,6 +46,7 @@ describe('parsePurchaseDates', () => {
|
|
|
46
46
|
const raw = {
|
|
47
47
|
skuId: 'com.example.monthly',
|
|
48
48
|
transactionIdentifier: 'txn_123',
|
|
49
|
+
originalTransactionIdentifier: 'orig_txn_456',
|
|
49
50
|
purchaseSource: 'CAMPAIGN' as const,
|
|
50
51
|
purchaseInitiatedTimestamp: 1700000000000,
|
|
51
52
|
sku: { id: 'sku_1', skuId: 'com.example.monthly', type: 'subscription' },
|
|
@@ -54,9 +55,21 @@ describe('parsePurchaseDates', () => {
|
|
|
54
55
|
|
|
55
56
|
expect(result.skuId).toBe('com.example.monthly');
|
|
56
57
|
expect(result.transactionIdentifier).toBe('txn_123');
|
|
58
|
+
expect(result.originalTransactionIdentifier).toBe('orig_txn_456');
|
|
57
59
|
expect(result.purchaseSource).toBe('CAMPAIGN');
|
|
58
60
|
expect(result.sku).toEqual(raw.sku);
|
|
59
61
|
});
|
|
62
|
+
|
|
63
|
+
it('leaves originalTransactionIdentifier undefined when the bridge omits it', () => {
|
|
64
|
+
const raw = {
|
|
65
|
+
skuId: 'com.example.monthly',
|
|
66
|
+
transactionIdentifier: 'txn_123',
|
|
67
|
+
purchaseInitiatedTimestamp: 1700000000000,
|
|
68
|
+
};
|
|
69
|
+
const result = parsePurchaseDates(raw);
|
|
70
|
+
|
|
71
|
+
expect(result.originalTransactionIdentifier).toBeUndefined();
|
|
72
|
+
});
|
|
60
73
|
});
|
|
61
74
|
|
|
62
75
|
describe('coerceSkuType', () => {
|
|
@@ -105,14 +118,18 @@ describe('parseEntitlements', () => {
|
|
|
105
118
|
desc: 'Premium access',
|
|
106
119
|
referenceId: 'premium',
|
|
107
120
|
activePurchases: [rawPurchase],
|
|
108
|
-
purchasedSkus: [
|
|
121
|
+
purchasedSkus: [
|
|
122
|
+
{ id: 'sku_1', skuId: 'com.example.monthly', type: 'subscription' },
|
|
123
|
+
],
|
|
109
124
|
relatedSkus: [],
|
|
110
125
|
},
|
|
111
126
|
];
|
|
112
127
|
const result = parseEntitlements(raw);
|
|
113
128
|
|
|
114
129
|
expect(result).toHaveLength(1);
|
|
115
|
-
expect(
|
|
130
|
+
expect(
|
|
131
|
+
result[0].activePurchases[0].purchaseInitiatedTimestamp,
|
|
132
|
+
).toBeInstanceOf(Date);
|
|
116
133
|
expect(result[0].activePurchases[0].expires).toBeInstanceOf(Date);
|
|
117
134
|
});
|
|
118
135
|
|
|
@@ -132,7 +149,11 @@ describe('parseEntitlements', () => {
|
|
|
132
149
|
});
|
|
133
150
|
|
|
134
151
|
it('preserves existing relatedSkus and purchasedSkus', () => {
|
|
135
|
-
const sku = {
|
|
152
|
+
const sku = {
|
|
153
|
+
id: 'sku_1',
|
|
154
|
+
skuId: 'com.example.monthly',
|
|
155
|
+
type: 'subscription',
|
|
156
|
+
};
|
|
136
157
|
const raw = [
|
|
137
158
|
{
|
|
138
159
|
name: 'Premium',
|
package/src/types.ts
CHANGED
|
@@ -203,12 +203,21 @@ export type FailureResultObject = {
|
|
|
203
203
|
error: string;
|
|
204
204
|
};
|
|
205
205
|
|
|
206
|
+
/**
|
|
207
|
+
* Permitted value types for entries in {@link PaywallLaunchContext.customAttributes}.
|
|
208
|
+
*
|
|
209
|
+
* Both native primitives and their string equivalents are accepted; the underlying
|
|
210
|
+
* Apple/Android SDKs treat the two wire formats identically when evaluating
|
|
211
|
+
* targeting predicates.
|
|
212
|
+
*/
|
|
213
|
+
export type CustomAttributeValue = string | boolean | number;
|
|
214
|
+
|
|
206
215
|
export type PaywallLaunchContext = {
|
|
207
216
|
// Can contain multiple product group identifiers
|
|
208
217
|
productGroups?: string[];
|
|
209
218
|
// Key-value pairs used to override template values
|
|
210
219
|
customAttributes: {
|
|
211
|
-
[key: string]:
|
|
220
|
+
[key: string]: CustomAttributeValue;
|
|
212
221
|
};
|
|
213
222
|
// Custom object used as data source for advanced paywall components
|
|
214
223
|
customObject?: {
|
|
@@ -322,6 +331,7 @@ export type NamiPurchase = {
|
|
|
322
331
|
sku?: NamiSKU;
|
|
323
332
|
skuId: string;
|
|
324
333
|
transactionIdentifier?: string;
|
|
334
|
+
originalTransactionIdentifier?: string;
|
|
325
335
|
purchaseToken?: string;
|
|
326
336
|
expires?: Date;
|
|
327
337
|
purchaseInitiatedTimestamp: Date;
|
|
@@ -332,6 +342,7 @@ export type NamiPurchaseFromBridge = {
|
|
|
332
342
|
sku?: NamiSKU;
|
|
333
343
|
skuId: string;
|
|
334
344
|
transactionIdentifier?: string;
|
|
345
|
+
originalTransactionIdentifier?: string;
|
|
335
346
|
purchaseToken?: string;
|
|
336
347
|
expires?: number;
|
|
337
348
|
purchaseInitiatedTimestamp: number;
|
package/src/version.ts
CHANGED