insert-affiliate-react-native-sdk 1.10.0 → 1.11.2
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/.claude/settings.local.json +8 -2
- package/dist/DeepLinkIapProvider.js +264 -151
- package/docs/deep-linking-appsflyer.md +24 -2
- package/docs/deep-linking-branch.md +24 -2
- package/package.json +1 -1
- package/readme.md +72 -22
- package/src/DeepLinkIapProvider.tsx +237 -91
|
@@ -64,6 +64,7 @@ const DeepLinkHandler = () => {
|
|
|
64
64
|
|
|
65
65
|
if (insertAffiliateIdentifier) {
|
|
66
66
|
await Purchases.setAttributes({ "insert_affiliate": insertAffiliateIdentifier });
|
|
67
|
+
await Purchases.syncAttributesAndOfferingsIfNeeded();
|
|
67
68
|
}
|
|
68
69
|
} catch (err) {
|
|
69
70
|
console.error('Error setting affiliate identifier:', err);
|
|
@@ -102,7 +103,7 @@ AppRegistry.registerComponent(appName, () => RootComponent);
|
|
|
102
103
|
### Example with Adapty
|
|
103
104
|
|
|
104
105
|
```javascript
|
|
105
|
-
import React, { useEffect } from 'react';
|
|
106
|
+
import React, { useEffect, useRef } from 'react';
|
|
106
107
|
import { AppRegistry, Platform } from 'react-native';
|
|
107
108
|
import appsFlyer from 'react-native-appsflyer';
|
|
108
109
|
import { adapty } from 'react-native-adapty';
|
|
@@ -112,6 +113,25 @@ import { name as appName } from './app.json';
|
|
|
112
113
|
|
|
113
114
|
const DeepLinkHandler = () => {
|
|
114
115
|
const { setInsertAffiliateIdentifier, isInitialized } = useDeepLinkIapProvider();
|
|
116
|
+
const adaptyActivationPromiseRef = useRef(null);
|
|
117
|
+
|
|
118
|
+
// Initialize Adapty SDK
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
const initAdapty = async () => {
|
|
121
|
+
try {
|
|
122
|
+
adaptyActivationPromiseRef.current = adapty.activate('YOUR_ADAPTY_PUBLIC_SDK_KEY', {
|
|
123
|
+
__ignoreActivationOnFastRefresh: __DEV__,
|
|
124
|
+
});
|
|
125
|
+
await adaptyActivationPromiseRef.current;
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.error('Failed to activate Adapty SDK:', error);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
if (!adaptyActivationPromiseRef.current) {
|
|
132
|
+
initAdapty();
|
|
133
|
+
}
|
|
134
|
+
}, []);
|
|
115
135
|
|
|
116
136
|
useEffect(() => {
|
|
117
137
|
if (!isInitialized) return;
|
|
@@ -138,7 +158,9 @@ const DeepLinkHandler = () => {
|
|
|
138
158
|
try {
|
|
139
159
|
const insertAffiliateIdentifier = await setInsertAffiliateIdentifier(referringLink);
|
|
140
160
|
|
|
141
|
-
if (insertAffiliateIdentifier) {
|
|
161
|
+
if (insertAffiliateIdentifier && adaptyActivationPromiseRef.current) {
|
|
162
|
+
// Wait for Adapty activation before updating profile
|
|
163
|
+
await adaptyActivationPromiseRef.current;
|
|
142
164
|
await adapty.updateProfile({
|
|
143
165
|
codableCustomAttributes: {
|
|
144
166
|
insert_affiliate: insertAffiliateIdentifier,
|
|
@@ -50,6 +50,7 @@ const DeepLinkHandler = () => {
|
|
|
50
50
|
|
|
51
51
|
if (insertAffiliateIdentifier) {
|
|
52
52
|
await Purchases.setAttributes({ "insert_affiliate": insertAffiliateIdentifier });
|
|
53
|
+
await Purchases.syncAttributesAndOfferingsIfNeeded();
|
|
53
54
|
}
|
|
54
55
|
} catch (err) {
|
|
55
56
|
console.error('Error setting affiliate identifier:', err);
|
|
@@ -80,7 +81,7 @@ AppRegistry.registerComponent(appName, () => RootComponent);
|
|
|
80
81
|
### Example with Adapty
|
|
81
82
|
|
|
82
83
|
```javascript
|
|
83
|
-
import React, { useEffect } from 'react';
|
|
84
|
+
import React, { useEffect, useRef } from 'react';
|
|
84
85
|
import { AppRegistry } from 'react-native';
|
|
85
86
|
import branch from 'react-native-branch';
|
|
86
87
|
import { adapty } from 'react-native-adapty';
|
|
@@ -90,6 +91,25 @@ import { name as appName } from './app.json';
|
|
|
90
91
|
|
|
91
92
|
const DeepLinkHandler = () => {
|
|
92
93
|
const { setInsertAffiliateIdentifier } = useDeepLinkIapProvider();
|
|
94
|
+
const adaptyActivationPromiseRef = useRef(null);
|
|
95
|
+
|
|
96
|
+
// Initialize Adapty SDK
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
const initAdapty = async () => {
|
|
99
|
+
try {
|
|
100
|
+
adaptyActivationPromiseRef.current = adapty.activate('YOUR_ADAPTY_PUBLIC_SDK_KEY', {
|
|
101
|
+
__ignoreActivationOnFastRefresh: __DEV__,
|
|
102
|
+
});
|
|
103
|
+
await adaptyActivationPromiseRef.current;
|
|
104
|
+
} catch (error) {
|
|
105
|
+
console.error('Failed to activate Adapty SDK:', error);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
if (!adaptyActivationPromiseRef.current) {
|
|
110
|
+
initAdapty();
|
|
111
|
+
}
|
|
112
|
+
}, []);
|
|
93
113
|
|
|
94
114
|
useEffect(() => {
|
|
95
115
|
const branchSubscription = branch.subscribe(async ({ error, params }) => {
|
|
@@ -104,7 +124,9 @@ const DeepLinkHandler = () => {
|
|
|
104
124
|
try {
|
|
105
125
|
const insertAffiliateIdentifier = await setInsertAffiliateIdentifier(referringLink);
|
|
106
126
|
|
|
107
|
-
if (insertAffiliateIdentifier) {
|
|
127
|
+
if (insertAffiliateIdentifier && adaptyActivationPromiseRef.current) {
|
|
128
|
+
// Wait for Adapty activation before updating profile
|
|
129
|
+
await adaptyActivationPromiseRef.current;
|
|
108
130
|
await adapty.updateProfile({
|
|
109
131
|
codableCustomAttributes: {
|
|
110
132
|
insert_affiliate: insertAffiliateIdentifier,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "insert-affiliate-react-native-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.2",
|
|
4
4
|
"description": "A package for connecting with the Insert Affiliate Platform to add app based affiliate marketing.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
package/readme.md
CHANGED
|
@@ -193,6 +193,7 @@ const App = () => {
|
|
|
193
193
|
setInsertAffiliateIdentifierChangeCallback(async (identifier) => {
|
|
194
194
|
if (identifier) {
|
|
195
195
|
await Purchases.setAttributes({ "insert_affiliate": identifier });
|
|
196
|
+
await Purchases.syncAttributesAndOfferingsIfNeeded();
|
|
196
197
|
}
|
|
197
198
|
});
|
|
198
199
|
|
|
@@ -234,7 +235,7 @@ Complete the [Adapty SDK installation](https://adapty.io/docs/sdk-installation-r
|
|
|
234
235
|
**Step 2: Code Setup**
|
|
235
236
|
|
|
236
237
|
```javascript
|
|
237
|
-
import React, { useEffect } from 'react';
|
|
238
|
+
import React, { useEffect, useRef } from 'react';
|
|
238
239
|
import { adapty } from 'react-native-adapty';
|
|
239
240
|
import { useDeepLinkIapProvider } from 'insert-affiliate-react-native-sdk';
|
|
240
241
|
|
|
@@ -242,30 +243,53 @@ const ADAPTY_PUBLIC_SDK_KEY = 'YOUR_ADAPTY_PUBLIC_SDK_KEY'; // From https://app.
|
|
|
242
243
|
|
|
243
244
|
const App = () => {
|
|
244
245
|
const { initialize, isInitialized, setInsertAffiliateIdentifierChangeCallback } = useDeepLinkIapProvider();
|
|
246
|
+
const adaptyActivationPromiseRef = useRef(null);
|
|
245
247
|
|
|
246
|
-
// Initialize
|
|
248
|
+
// Initialize Adapty SDK
|
|
247
249
|
useEffect(() => {
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
250
|
+
const initAdapty = async () => {
|
|
251
|
+
try {
|
|
252
|
+
adaptyActivationPromiseRef.current = adapty.activate(ADAPTY_PUBLIC_SDK_KEY, {
|
|
253
|
+
__ignoreActivationOnFastRefresh: __DEV__,
|
|
254
|
+
});
|
|
255
|
+
await adaptyActivationPromiseRef.current;
|
|
256
|
+
} catch (error) {
|
|
257
|
+
console.error('Failed to activate Adapty SDK:', error);
|
|
255
258
|
}
|
|
256
259
|
};
|
|
257
|
-
|
|
260
|
+
|
|
261
|
+
if (!adaptyActivationPromiseRef.current) {
|
|
262
|
+
initAdapty();
|
|
263
|
+
}
|
|
264
|
+
}, []);
|
|
265
|
+
|
|
266
|
+
// Initialize Insert Affiliate SDK
|
|
267
|
+
useEffect(() => {
|
|
268
|
+
if (!isInitialized) {
|
|
269
|
+
initialize("YOUR_COMPANY_CODE");
|
|
270
|
+
}
|
|
258
271
|
}, [initialize, isInitialized]);
|
|
259
272
|
|
|
260
273
|
// Set Adapty attribute when affiliate identifier changes
|
|
261
274
|
useEffect(() => {
|
|
262
275
|
setInsertAffiliateIdentifierChangeCallback(async (identifier) => {
|
|
263
276
|
if (identifier) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
277
|
+
if (adaptyActivationPromiseRef.current) {
|
|
278
|
+
try {
|
|
279
|
+
// Wait for Adapty activation before updating profile
|
|
280
|
+
await adaptyActivationPromiseRef.current;
|
|
281
|
+
|
|
282
|
+
await adapty.updateProfile({
|
|
283
|
+
codableCustomAttributes: {
|
|
284
|
+
insert_affiliate: identifier,
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
} catch (error) {
|
|
288
|
+
console.error('Failed to update Adapty profile with affiliate identifier:', error);
|
|
289
|
+
}
|
|
290
|
+
} else {
|
|
291
|
+
console.error('Adapty SDK is not initialized');
|
|
292
|
+
}
|
|
269
293
|
}
|
|
270
294
|
});
|
|
271
295
|
|
|
@@ -489,6 +513,7 @@ const App = () => {
|
|
|
489
513
|
setInsertAffiliateIdentifierChangeCallback(async (identifier) => {
|
|
490
514
|
if (identifier) {
|
|
491
515
|
await Purchases.setAttributes({ "insert_affiliate": identifier });
|
|
516
|
+
await Purchases.syncAttributesAndOfferingsIfNeeded();
|
|
492
517
|
}
|
|
493
518
|
});
|
|
494
519
|
|
|
@@ -502,25 +527,50 @@ const App = () => {
|
|
|
502
527
|
**With Adapty:**
|
|
503
528
|
|
|
504
529
|
```javascript
|
|
530
|
+
import React, { useEffect, useRef } from 'react';
|
|
505
531
|
import { useDeepLinkIapProvider } from 'insert-affiliate-react-native-sdk';
|
|
506
532
|
import { adapty } from 'react-native-adapty';
|
|
507
533
|
|
|
508
534
|
const App = () => {
|
|
509
535
|
const { setInsertAffiliateIdentifierChangeCallback } = useDeepLinkIapProvider();
|
|
536
|
+
const adaptyActivationPromiseRef = useRef(null);
|
|
510
537
|
|
|
538
|
+
// Initialize Adapty SDK (see Option 2: Adapty for full setup)
|
|
511
539
|
useEffect(() => {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
insert_affiliate: identifier,
|
|
517
|
-
},
|
|
540
|
+
const initAdapty = async () => {
|
|
541
|
+
try {
|
|
542
|
+
adaptyActivationPromiseRef.current = adapty.activate('YOUR_ADAPTY_PUBLIC_SDK_KEY', {
|
|
543
|
+
__ignoreActivationOnFastRefresh: __DEV__,
|
|
518
544
|
});
|
|
545
|
+
await adaptyActivationPromiseRef.current;
|
|
546
|
+
} catch (error) {
|
|
547
|
+
console.error('Failed to activate Adapty SDK:', error);
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
if (!adaptyActivationPromiseRef.current) {
|
|
552
|
+
initAdapty();
|
|
553
|
+
}
|
|
554
|
+
}, []);
|
|
555
|
+
|
|
556
|
+
useEffect(() => {
|
|
557
|
+
setInsertAffiliateIdentifierChangeCallback(async (identifier) => {
|
|
558
|
+
if (identifier && adaptyActivationPromiseRef.current) {
|
|
559
|
+
try {
|
|
560
|
+
await adaptyActivationPromiseRef.current;
|
|
561
|
+
await adapty.updateProfile({
|
|
562
|
+
codableCustomAttributes: {
|
|
563
|
+
insert_affiliate: identifier,
|
|
564
|
+
},
|
|
565
|
+
});
|
|
566
|
+
} catch (error) {
|
|
567
|
+
console.error('Failed to update Adapty profile:', error);
|
|
568
|
+
}
|
|
519
569
|
}
|
|
520
570
|
});
|
|
521
571
|
|
|
522
572
|
return () => setInsertAffiliateIdentifierChangeCallback(null);
|
|
523
|
-
}, []);
|
|
573
|
+
}, [setInsertAffiliateIdentifierChangeCallback]);
|
|
524
574
|
|
|
525
575
|
return <YourAppContent />;
|
|
526
576
|
};
|