ReviewOS

craft-native/craft

iOS: a scheduled notification drops its data, so a tap on it hands the page {}

#258
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Found while working on #256.

The SDK's NotificationOptions has data?: Record<string, unknown> ("Custom data payload"), and notifications.show / schedule pass it to the bridge. On iOS, neither scheduler puts it anywhere:

  • Swift: scheduleLocalNotification in packages/ios/templates/CraftApp.swift sets title, body, subtitle, badge and sound on the UNMutableNotificationContent, and never sets userInfo.
  • Zig: bridge_mobile_notifications.zig reads title, body and badge from the request (around line 745), and never sets userInfo either.

A tap hands the page content.userInfo (#255), and so does an arrival while the app is open (#256). So a local notification scheduled with data: { screen: 'plant-id' } reaches pushNotifications.onNotification as {}. The page can't route on it, which is exactly the "Try it →" case. Remote pushes aren't affected, because their custom keys are already in userInfo.

Fix: set content.userInfo from data in both schedulers. Values need to be property-list types, which JSON already is. Add a test that fails without the fix on each side. The mobile E2E harness can check it end to end the way #257 checks pushes: schedule with data, kill the app, and tap the banner.

Sign in to comment on this issue.