@loyalytics/swan-react-native-sdk 2.7.1-beta.0 → 2.7.1-beta.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.
@@ -173,7 +173,15 @@ class NotificationViewController: UIViewController, UNNotificationContentExtensi
173
173
  completion: @escaping (Bool) -> Void
174
174
  ) {
175
175
  let messageId = userInfo["messageId"] as? String ?? ""
176
- let route = itemRoute ?? userInfo["defaultRoute"] as? String ?? ""
176
+ let defaultRoute = userInfo["defaultRoute"] as? String
177
+ // Use per-item route if non-nil and non-empty, otherwise fall back to defaultRoute.
178
+ // Logic mirrors SwanParsers.resolveRoute() — keep in sync.
179
+ let route: String
180
+ if let itemRoute = itemRoute, !itemRoute.isEmpty {
181
+ route = itemRoute
182
+ } else {
183
+ route = defaultRoute ?? ""
184
+ }
177
185
 
178
186
  // Always save click data first — the async extensionContext.open() completion
179
187
  // uses [weak self], so saveClickData() could be skipped if self is deallocated.
@@ -1919,9 +1919,18 @@ class SwanSDK {
1919
1919
  this.sendNotificationAck(messageId, 'clicked');
1920
1920
  }
1921
1921
 
1922
+ // Normalize route: strip custom URL schemes (e.g., "swanexample://offer/999" → "offer/999")
1923
+ // iOS carousel routes must be full URLs for Content Extension's extensionContext.open(),
1924
+ // but host apps expect consistent relative routes across all platforms and notification types.
1925
+ // Preserve http:// and https:// — those are web links the host app may open in a browser.
1926
+ let normalizedRoute = route;
1927
+ if (normalizedRoute && normalizedRoute.includes('://') && !normalizedRoute.startsWith('http://') && !normalizedRoute.startsWith('https://')) {
1928
+ normalizedRoute = normalizedRoute.split('://').slice(1).join('://');
1929
+ }
1930
+
1922
1931
  // Emit NOTIFICATION_OPENED event (same as Notifee click handler)
1923
1932
  const deepLinkPayload = {
1924
- route: route || undefined,
1933
+ route: normalizedRoute || undefined,
1925
1934
  title: title || undefined,
1926
1935
  body: body || undefined,
1927
1936
  keyValuePairs: {}