ReviewOS

also looking at this

craft-native/craft

fix(ios): schedule a notification with the data the page gave it

#262
Merged glennmichael123 wants to merge fix/ios-notification-data into main
8 files +242 -22
packages/ios/src/index.test.tsmodified+14-0
Changes to packages/ios/src/index.test.ts
@@ -393,6 +393,20 @@ describe('Craft iOS builder', () => {
393393 expect(handle.slice(0, handle.indexOf('\n }\n'))).toContain('sendToWeb("craftNotificationReceived"')
394394 })
395395
396 it('schedules a local notification with the data the page gave it', async () => {
397 // #258: `data` never reached userInfo, so a tap on a scheduled
398 // notification handed the page {} and it had nothing to route on.
399 const output = mkdtempSync(join(tmpdir(), 'craft-ios-notification-data-'))
400 await init({ name: 'WildLoop', bundleId: 'org.wildloop.app', output, config: { enableLocalNotifications: true } })
401 const swift = readFileSync(join(output, 'Sources', 'WildLoopApp.swift'), 'utf8')
402
403 const schedule = swift.slice(swift.indexOf('private func scheduleLocalNotification('))
404 const body = schedule.slice(0, schedule.indexOf('\n }\n'))
405 expect(body).toContain('if let info = data["data"] as? [String: Any] { content.userInfo = info }')
406 // Set on the content the request is made from, before it is filed.
407 expect(body.indexOf('content.userInfo = info')).toBeLessThan(body.indexOf('UNNotificationRequest(identifier: id, content: content'))
408 })
409
396410 it('settles calendar callbacks only after a real EventKit operation', async () => {
397411 const output = mkdtempSync(join(tmpdir(), 'craft-ios-calendar-'))
398412 await init({