also looking at this
fix(ios): schedule a notification with the data the page gave it
#262
8 files
+242
-22
| @@ -393,6 +393,20 @@ describe('Craft iOS builder', () => { | ||
| 393 | 393 | expect(handle.slice(0, handle.indexOf('\n }\n'))).toContain('sendToWeb("craftNotificationReceived"') |
| 394 | 394 | }) |
| 395 | 395 | |
| 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 | ||
| 396 | 410 | it('settles calendar callbacks only after a real EventKit operation', async () => { |
| 397 | 411 | const output = mkdtempSync(join(tmpdir(), 'craft-ios-calendar-')) |
| 398 | 412 | await init({ |