also looking at this
fix(ios): schedule a notification with the data the page gave it
#262
8 files
+242
-22
| @@ -18,6 +18,7 @@ | ||
| 18 | 18 | <p id="notification-permission"></p> |
| 19 | 19 | <p id="notification"></p> |
| 20 | 20 | <p id="notification-received"></p> |
| 21 | <p id="notification-local"></p> | |
| 21 | 22 | <script> |
| 22 | 23 | // The page drives itself and reports through the bridge's own `log` action, |
| 23 | 24 | // which is the one channel both runtimes already forward off-device: iOS |
| @@ -510,6 +511,10 @@ | ||
| 510 | 511 | // what onReceive handed it, and how many taps it had by then, since an |
| 511 | 512 | // arrival is not a tap. |
| 512 | 513 | // |
| 514 | // #258: opened by the local link, the page schedules a notification of | |
| 515 | // its own, with data, a few seconds out. The test kills the app before it | |
| 516 | // fires and taps it, and this same report says what the tap carried. | |
| 517 | // | |
| 513 | 518 | // Permission is asked for only when the link asks, because nothing |
| 514 | 519 | // answers the prompt on the launches simctl makes. iOS only: Android has |
| 515 | 520 | // no tap path to test yet. |
| @@ -520,6 +525,15 @@ | ||
| 520 | 525 | var said = function (text) { document.getElementById('notification-permission').textContent = 'CRAFT-E2E-NOTIFY-PERMISSION ' + text } |
| 521 | 526 | window.craft.permissions.request('notifications').then(said, function (error) { said('rejected ' + describeError(error).message) }) |
| 522 | 527 | } |
| 528 | if (launch && launch.url.indexOf('://e2e/local') !== -1) { | |
| 529 | var scheduled = function (text) { document.getElementById('notification-local').textContent = 'CRAFT-E2E-LOCAL-SCHEDULED ' + text } | |
| 530 | window.craft.notifications.schedule({ | |
| 531 | title: 'Craft E2E', | |
| 532 | body: NONCE + ' local', | |
| 533 | delay: 8000, | |
| 534 | data: { craftE2E: NONCE, stage: 'local', nested: { kept: true } } | |
| 535 | }).then(function () { scheduled('ok') }, function (error) { scheduled('rejected ' + describeError(error).message) }) | |
| 536 | } | |
| 523 | 537 | var onTap = window.craft.notifications && window.craft.notifications.onTap |
| 524 | 538 | var seen = { dispatched: 0, taps: [], onTap: typeof onTap, unsubscribe: null } |
| 525 | 539 | if (typeof onTap === 'function') { |