insert-affiliate-react-native-sdk 1.2.5 → 1.2.6
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.
|
@@ -12,7 +12,7 @@ type T_DEEPLINK_IAP_CONTEXT = {
|
|
|
12
12
|
validatePurchaseWithIapticAPI: (jsonIapPurchase: CustomPurchase, iapticAppId: string, iapticAppName: string, iapticPublicKey: string) => Promise<boolean>;
|
|
13
13
|
trackEvent: (eventName: string) => Promise<void>;
|
|
14
14
|
setShortCode: (shortCode: string) => Promise<void>;
|
|
15
|
-
setInsertAffiliateIdentifier: (referringLink: string
|
|
15
|
+
setInsertAffiliateIdentifier: (referringLink: string) => Promise<void>;
|
|
16
16
|
initialize: (code: string | null) => Promise<void>;
|
|
17
17
|
isInitialized: boolean;
|
|
18
18
|
};
|
package/package.json
CHANGED
|
@@ -24,10 +24,7 @@ type T_DEEPLINK_IAP_CONTEXT = {
|
|
|
24
24
|
) => Promise<boolean>;
|
|
25
25
|
trackEvent: (eventName: string) => Promise<void>;
|
|
26
26
|
setShortCode: (shortCode: string) => Promise<void>;
|
|
27
|
-
setInsertAffiliateIdentifier: (
|
|
28
|
-
referringLink: string,
|
|
29
|
-
completion: (shortLink: string | null) => void
|
|
30
|
-
) => Promise<void>;
|
|
27
|
+
setInsertAffiliateIdentifier: (referringLink: string) => Promise<void>;
|
|
31
28
|
initialize: (code: string | null) => Promise<void>;
|
|
32
29
|
isInitialized: boolean;
|
|
33
30
|
};
|
|
@@ -67,10 +64,7 @@ export const DeepLinkIapContext = createContext<T_DEEPLINK_IAP_CONTEXT>({
|
|
|
67
64
|
) => false,
|
|
68
65
|
trackEvent: async (eventName: string) => {},
|
|
69
66
|
setShortCode: async (shortCode: string) => {},
|
|
70
|
-
setInsertAffiliateIdentifier: async (
|
|
71
|
-
referringLink: string,
|
|
72
|
-
completion: (shortLink: string | null) => void
|
|
73
|
-
) => {},
|
|
67
|
+
setInsertAffiliateIdentifier: async (referringLink: string) => {},
|
|
74
68
|
initialize: async (code: string | null) => {},
|
|
75
69
|
isInitialized: false
|
|
76
70
|
});
|
|
@@ -206,27 +200,22 @@ const DeepLinkIapProvider: React.FC<T_DEEPLINK_IAP_PROVIDER> = ({
|
|
|
206
200
|
|
|
207
201
|
|
|
208
202
|
// MARK: Insert Affiliate Identifier
|
|
209
|
-
const setInsertAffiliateIdentifier = async (
|
|
210
|
-
referringLink: string,
|
|
211
|
-
completion: (shortLink: string | null) => void
|
|
212
|
-
) => {
|
|
203
|
+
const setInsertAffiliateIdentifier = async (referringLink: string) => {
|
|
213
204
|
console.log("[Insert Affiliate] Setting affiliate identifier.");
|
|
214
205
|
|
|
215
206
|
try {
|
|
216
|
-
generateThenSetUserID();
|
|
207
|
+
await generateThenSetUserID();
|
|
217
208
|
|
|
218
209
|
console.log("[Insert Affiliate] Completed generateThenSetUserID within setInsertAffiliateIdentifier.");
|
|
219
210
|
|
|
220
211
|
if (!referringLink) {
|
|
221
212
|
console.warn("[Insert Affiliate] Referring link is invalid.");
|
|
222
|
-
storeInsertAffiliateIdentifier({ link: referringLink });
|
|
223
|
-
completion(null);
|
|
213
|
+
await storeInsertAffiliateIdentifier({ link: referringLink });
|
|
224
214
|
return;
|
|
225
215
|
}
|
|
226
216
|
|
|
227
217
|
if (!isInitialized || !companyCode) {
|
|
228
218
|
console.error("[Insert Affiliate] SDK is not initialized. Please initialize the SDK with a valid company code.");
|
|
229
|
-
completion(null);
|
|
230
219
|
return;
|
|
231
220
|
}
|
|
232
221
|
|
|
@@ -234,15 +223,13 @@ const DeepLinkIapProvider: React.FC<T_DEEPLINK_IAP_PROVIDER> = ({
|
|
|
234
223
|
console.error(
|
|
235
224
|
"[Insert Affiliate] Company code is not set. Please initialize the SDK with a valid company code."
|
|
236
225
|
);
|
|
237
|
-
completion(null);
|
|
238
226
|
return;
|
|
239
227
|
}
|
|
240
228
|
|
|
241
229
|
// Check if referring link is already a short code, if so save it and stop here.
|
|
242
230
|
if (isShortCode(referringLink)) {
|
|
243
231
|
console.log("[Insert Affiliate] Referring link is already a short code.");
|
|
244
|
-
storeInsertAffiliateIdentifier({ link: referringLink });
|
|
245
|
-
completion(referringLink);
|
|
232
|
+
await storeInsertAffiliateIdentifier({ link: referringLink });
|
|
246
233
|
return;
|
|
247
234
|
}
|
|
248
235
|
|
|
@@ -251,8 +238,7 @@ const DeepLinkIapProvider: React.FC<T_DEEPLINK_IAP_PROVIDER> = ({
|
|
|
251
238
|
const encodedAffiliateLink = encodeURIComponent(referringLink);
|
|
252
239
|
if (!encodedAffiliateLink) {
|
|
253
240
|
console.error("[Insert Affiliate] Failed to encode affiliate link.");
|
|
254
|
-
storeInsertAffiliateIdentifier({ link: referringLink });
|
|
255
|
-
completion(null);
|
|
241
|
+
await storeInsertAffiliateIdentifier({ link: referringLink });
|
|
256
242
|
return;
|
|
257
243
|
}
|
|
258
244
|
|
|
@@ -269,16 +255,13 @@ const DeepLinkIapProvider: React.FC<T_DEEPLINK_IAP_PROVIDER> = ({
|
|
|
269
255
|
if (response.status === 200 && response.data.shortLink) {
|
|
270
256
|
const shortLink = response.data.shortLink;
|
|
271
257
|
console.log("[Insert Affiliate] Short link received:", shortLink);
|
|
272
|
-
storeInsertAffiliateIdentifier({ link: shortLink });
|
|
273
|
-
completion(shortLink);
|
|
258
|
+
await storeInsertAffiliateIdentifier({ link: shortLink });
|
|
274
259
|
} else {
|
|
275
260
|
console.warn("[Insert Affiliate] Unexpected response format.");
|
|
276
|
-
storeInsertAffiliateIdentifier({ link: referringLink });
|
|
277
|
-
completion(null);
|
|
261
|
+
await storeInsertAffiliateIdentifier({ link: referringLink });
|
|
278
262
|
}
|
|
279
263
|
} catch (error) {
|
|
280
264
|
console.error("[Insert Affiliate] Error:", error);
|
|
281
|
-
completion(null);
|
|
282
265
|
}
|
|
283
266
|
};
|
|
284
267
|
|