also looking at this
feat(ios): tell the page about a notification that arrives while the app is open
#259
11 files
+410
-58
| @@ -376,6 +376,23 @@ describe('Craft iOS builder', () => { | ||
| 376 | 376 | expect(handle.slice(0, handle.indexOf('\n }\n'))).toContain('sendToWeb("craftNotificationResponse"') |
| 377 | 377 | }) |
| 378 | 378 | |
| 379 | it('tells the page about a notification that arrives while the app is open', async () => { | |
| 380 | // willPresent used to show the banner and nothing else, so a page on | |
| 381 | // screen when a push landed heard about it only if someone tapped it. | |
| 382 | const output = mkdtempSync(join(tmpdir(), 'craft-ios-notification-received-')) | |
| 383 | await init({ name: 'WildLoop', bundleId: 'org.wildloop.app', output }) | |
| 384 | const swift = readFileSync(join(output, 'Sources', 'WildLoopApp.swift'), 'utf8') | |
| 385 | ||
| 386 | const willPresent = swift.slice(swift.indexOf('willPresent notification: UNNotification')) | |
| 387 | const body = willPresent.slice(0, willPresent.indexOf('\n }\n')) | |
| 388 | expect(body).toContain('CraftEventManager.shared.handleNotificationReceived(notification.request.content.userInfo)') | |
| 389 | // Told, not asked: the banner still shows. | |
| 390 | expect(body).toContain('completionHandler([.banner, .badge, .sound])') | |
| 391 | ||
| 392 | const handle = swift.slice(swift.indexOf('func handleNotificationReceived(')) | |
| 393 | expect(handle.slice(0, handle.indexOf('\n }\n'))).toContain('sendToWeb("craftNotificationReceived"') | |
| 394 | }) | |
| 395 | ||
| 379 | 396 | it('settles calendar callbacks only after a real EventKit operation', async () => { |
| 380 | 397 | const output = mkdtempSync(join(tmpdir(), 'craft-ios-calendar-')) |
| 381 | 398 | await init({ |