@loyalytics/swan-react-native-sdk 2.5.1-beta.3 → 2.5.1-beta.4

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.
@@ -161,6 +161,7 @@ function _resetClickDedup() {
161
161
  class SwanSDK {
162
162
  listeners = {};
163
163
  coldStartCheckDone = false;
164
+ pendingNotificationPayload = null;
164
165
  SDK_VERSION = _version.SDK_VERSION;
165
166
  isProduction = 'STAGE';
166
167
  appId = '';
@@ -635,6 +636,15 @@ class SwanSDK {
635
636
  this.coldStartCheckDone = true;
636
637
  // Defer to next microtask so the listener is fully registered before events emit
637
638
  Promise.resolve().then(() => {
639
+ // Deliver buffered standard/image push notification (one-shot APIs like
640
+ // getInitialNotification() can't be re-read — data was buffered in emitNotificationOpened).
641
+ // Skip carousel notifications — checkPendingCarouselClick() handles those with per-item routes.
642
+ const payload = this.pendingNotificationPayload;
643
+ this.pendingNotificationPayload = null;
644
+ if (payload && payload.notificationType !== 'carousel') {
645
+ this.emitNotificationOpened(payload);
646
+ }
647
+ // Check for pending carousel click (native side holds data until consumed)
638
648
  this.checkPendingCarouselClick();
639
649
  });
640
650
  }
@@ -664,6 +674,15 @@ class SwanSDK {
664
674
  * @internal - Used by module-level notification handlers
665
675
  */
666
676
  emitNotificationOpened(payload) {
677
+ const listeners = this.listeners[SwanSDK.EVENTS.NOTIFICATION_OPENED];
678
+ if ((!listeners || listeners.length === 0) && !this.coldStartCheckDone) {
679
+ // Cold start: buffer for delivery when first listener registers.
680
+ // One-shot APIs like getInitialNotification() won't have this data later.
681
+ _Logger.default.log('[SwanSDK] Buffering notification payload for deferred delivery');
682
+ this.pendingNotificationPayload = payload;
683
+ return;
684
+ }
685
+ this.pendingNotificationPayload = null;
667
686
  this.emit(SwanSDK.EVENTS.NOTIFICATION_OPENED, payload);
668
687
  // Also emit unified deep link event for push source
669
688
  this.emitDeepLinkOpened({