@loyalytics/swan-react-native-sdk 2.5.1-beta.7 → 2.6.0
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 +27 -15
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/index.js +27 -15
- package/lib/module/index.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/version.d.ts +1 -1
- package/lib/typescript/commonjs/src/version.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/version.d.ts +1 -1
- package/lib/typescript/module/src/version.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/module/index.js
CHANGED
|
@@ -623,22 +623,32 @@ export default class SwanSDK {
|
|
|
623
623
|
}
|
|
624
624
|
this.listeners[event].push(callback);
|
|
625
625
|
|
|
626
|
-
// On
|
|
627
|
-
//
|
|
628
|
-
|
|
629
|
-
|
|
626
|
+
// On every NOTIFICATION_OPENED listener registration, check for buffered notifications.
|
|
627
|
+
// Runs on cold start (process dead → getInitialNotification buffered), warm restart
|
|
628
|
+
// (process alive but Activity destroyed by swipe-from-recents on Android), and
|
|
629
|
+
// Metro hot-reload (component unmount/remount cycles).
|
|
630
|
+
if (event === SwanSDK.EVENTS.NOTIFICATION_OPENED) {
|
|
630
631
|
// Defer to next microtask so the listener is fully registered before events emit
|
|
631
632
|
Promise.resolve().then(() => {
|
|
632
|
-
// Deliver buffered standard/image push notification
|
|
633
|
-
//
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
633
|
+
// Deliver buffered standard/image push notification.
|
|
634
|
+
// Skip carousel — checkPendingCarouselClick() handles those with per-item routes.
|
|
635
|
+
if (this.pendingNotificationPayload) {
|
|
636
|
+
const payload = this.pendingNotificationPayload;
|
|
637
|
+
this.pendingNotificationPayload = null;
|
|
638
|
+
if (payload.notificationType !== 'carousel') {
|
|
639
|
+
this.emit(SwanSDK.EVENTS.NOTIFICATION_OPENED, payload);
|
|
640
|
+
this.emitDeepLinkOpened({
|
|
641
|
+
...payload,
|
|
642
|
+
source: 'push'
|
|
643
|
+
});
|
|
644
|
+
}
|
|
639
645
|
}
|
|
640
|
-
// Check for pending carousel click (native side holds data until consumed)
|
|
646
|
+
// Check for pending carousel click (native side holds data until consumed).
|
|
647
|
+
// Unconditional: handles both cold start and warm restart carousel taps.
|
|
641
648
|
this.checkPendingCarouselClick();
|
|
649
|
+
if (!this.coldStartCheckDone) {
|
|
650
|
+
this.coldStartCheckDone = true;
|
|
651
|
+
}
|
|
642
652
|
});
|
|
643
653
|
}
|
|
644
654
|
|
|
@@ -668,9 +678,11 @@ export default class SwanSDK {
|
|
|
668
678
|
*/
|
|
669
679
|
emitNotificationOpened(payload) {
|
|
670
680
|
const listeners = this.listeners[SwanSDK.EVENTS.NOTIFICATION_OPENED];
|
|
671
|
-
if (
|
|
672
|
-
//
|
|
673
|
-
//
|
|
681
|
+
if (!listeners || listeners.length === 0) {
|
|
682
|
+
// No listeners yet — buffer for delivery when first listener registers.
|
|
683
|
+
// Handles: true cold start (process dead), Activity recreation (process alive
|
|
684
|
+
// but Activity destroyed by swipe-from-recents on Android), and Metro
|
|
685
|
+
// hot-reload (component unmount/remount cycles).
|
|
674
686
|
Logger.log('[SwanSDK] Buffering notification payload for deferred delivery');
|
|
675
687
|
this.pendingNotificationPayload = payload;
|
|
676
688
|
return;
|