@loyalytics/swan-react-native-sdk 2.5.1-beta.2 → 2.5.1-beta.3
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/lib/commonjs/index.js +16 -7
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/index.js +16 -7
- package/lib/module/index.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +1 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/version.d.ts +1 -1
- package/lib/typescript/module/src/index.d.ts +1 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/version.d.ts +1 -1
- package/package.json +1 -1
package/lib/module/index.js
CHANGED
|
@@ -145,6 +145,7 @@ export function _resetClickDedup() {
|
|
|
145
145
|
|
|
146
146
|
export default class SwanSDK {
|
|
147
147
|
listeners = {};
|
|
148
|
+
coldStartCheckDone = false;
|
|
148
149
|
SDK_VERSION = PACKAGE_VERSION;
|
|
149
150
|
isProduction = 'STAGE';
|
|
150
151
|
appId = '';
|
|
@@ -613,6 +614,16 @@ export default class SwanSDK {
|
|
|
613
614
|
}
|
|
614
615
|
this.listeners[event].push(callback);
|
|
615
616
|
|
|
617
|
+
// On first NOTIFICATION_OPENED listener, check for pending cold-start notifications.
|
|
618
|
+
// The native side holds click data until consumed — we just need to ask when ready.
|
|
619
|
+
if (event === SwanSDK.EVENTS.NOTIFICATION_OPENED && !this.coldStartCheckDone) {
|
|
620
|
+
this.coldStartCheckDone = true;
|
|
621
|
+
// Defer to next microtask so the listener is fully registered before events emit
|
|
622
|
+
Promise.resolve().then(() => {
|
|
623
|
+
this.checkPendingCarouselClick();
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
|
|
616
627
|
// Return a subscription object for easy cleanup
|
|
617
628
|
return {
|
|
618
629
|
remove: () => {
|
|
@@ -943,9 +954,6 @@ export default class SwanSDK {
|
|
|
943
954
|
Logger.log('[SwanSDK] Tracking initial app launch event...');
|
|
944
955
|
this.appLaunched();
|
|
945
956
|
|
|
946
|
-
// Check for pending carousel click (covers killed/quit → fresh launch)
|
|
947
|
-
this.checkPendingCarouselClick();
|
|
948
|
-
|
|
949
957
|
// AppState listener setup (always runs)
|
|
950
958
|
Logger.log('[SwanSDK] Setting up AppState listener...');
|
|
951
959
|
this.setupAppStateListener();
|
|
@@ -1811,11 +1819,12 @@ export default class SwanSDK {
|
|
|
1811
1819
|
// Read click data from App Group (written by Content Extension)
|
|
1812
1820
|
clickData = await SharedCredentialsManager.readTemplateClickData();
|
|
1813
1821
|
|
|
1814
|
-
//
|
|
1815
|
-
// The Content Extension may still be writing when the app foregrounds.
|
|
1822
|
+
// Exponential backoff: Content Extension may still be writing to App Group
|
|
1816
1823
|
if (!clickData) {
|
|
1817
|
-
|
|
1818
|
-
|
|
1824
|
+
for (let attempt = 0; attempt < 4 && !clickData; attempt++) {
|
|
1825
|
+
await new Promise(r => setTimeout(r, 100 * Math.pow(2, attempt)));
|
|
1826
|
+
clickData = await SharedCredentialsManager.readTemplateClickData();
|
|
1827
|
+
}
|
|
1819
1828
|
}
|
|
1820
1829
|
}
|
|
1821
1830
|
if (!clickData) return;
|