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
scripts/mobile-e2e/driver.htmlmodified+14-0
Changes to scripts/mobile-e2e/driver.html
@@ -18,6 +18,7 @@
1818 <p id="notification-permission"></p>
1919 <p id="notification"></p>
2020 <p id="notification-received"></p>
21 <p id="notification-local"></p>
2122 <script>
2223 // The page drives itself and reports through the bridge's own `log` action,
2324 // which is the one channel both runtimes already forward off-device: iOS
@@ -510,6 +511,10 @@
510511 // what onReceive handed it, and how many taps it had by then, since an
511512 // arrival is not a tap.
512513 //
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 //
513518 // Permission is asked for only when the link asks, because nothing
514519 // answers the prompt on the launches simctl makes. iOS only: Android has
515520 // no tap path to test yet.
@@ -520,6 +525,15 @@
520525 var said = function (text) { document.getElementById('notification-permission').textContent = 'CRAFT-E2E-NOTIFY-PERMISSION ' + text }
521526 window.craft.permissions.request('notifications').then(said, function (error) { said('rejected ' + describeError(error).message) })
522527 }
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 }
523537 var onTap = window.craft.notifications && window.craft.notifications.onTap
524538 var seen = { dispatched: 0, taps: [], onTap: typeof onTap, unsubscribe: null }
525539 if (typeof onTap === 'function') {