From ea48962eb2be4f61def4075160fdb1e570d4bebf Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Sat, 26 Sep 2026 16:00:05 +0800 Subject: [PATCH 1/8] fix: rebuild storefront push notifications on a single push channel Android pushes never worked with store-level FCM credentials and some iOS devices were rejected, because of several stacked defects: - configureFcm put the service account JSON into credentials.private_key, so no valid Firebase client was ever built from a store channel - FcmChannel required the platform-wide Firebase project to be configured - credentials were always resolved from the store, never the network app - one APNs environment per channel rejected sandbox/dev build tokens - registerDevice never reassigned a token to the latest customer and did not normalize platform casing - mail/database errors ran before push and stopped it; failures and dead tokens were never handled or logged Introduce Push\StorefrontPushChannel with isolated Firebase/APNs clients, network-first credential resolution with wrong-app and wrong-environment retries, dead token pruning, and high priority payloads. Order notifications share a StorefrontOrderNotification base class. Add a customers/unregister-device endpoint and an admin test push action. --- .../modals/create-notification-channel.hbs | 14 + .../modals/test-notification-channel.hbs | 33 ++ .../networks/index/network/index.js | 10 + addon/controllers/settings/notifications.js | 39 ++ .../networks/index/network/index.hbs | 1 + addon/templates/settings/notifications.hbs | 1 + addon/utils/get-notification-schemas.js | 5 +- .../modals/test-notification-channel.js | 1 + server/config/storefront.php | 13 + .../NotificationChannelController.php | 62 +++ .../Controllers/v1/CustomerController.php | 98 +++- server/src/Listeners/HandleOrderCompleted.php | 5 +- .../Listeners/HandleOrderDriverAssigned.php | 5 +- server/src/Listeners/HandleOrderStarted.php | 5 +- .../PromotionalPushNotification.php | 131 +---- .../Notifications/StorefrontOrderAccepted.php | 144 +---- .../Notifications/StorefrontOrderCanceled.php | 137 +---- .../StorefrontOrderCompleted.php | 144 +---- .../StorefrontOrderDriverAssigned.php | 146 +---- .../Notifications/StorefrontOrderEnroute.php | 144 +---- .../Notifications/StorefrontOrderNearby.php | 154 +---- .../StorefrontOrderNotification.php | 151 +++++ .../StorefrontOrderPreparing.php | 144 +---- .../StorefrontOrderReadyForPickup.php | 144 +---- server/src/Push/ApnClientFactory.php | 87 +++ .../Push/Contracts/SendsPushNotification.php | 28 + server/src/Push/FirebaseMessagingFactory.php | 87 +++ .../src/Push/PushConfigurationException.php | 7 + server/src/Push/PushCredentialResolver.php | 82 +++ server/src/Push/PushMessage.php | 193 +++++++ server/src/Push/PushOutcome.php | 58 ++ server/src/Push/StorefrontPushChannel.php | 236 ++++++++ server/src/Push/Transports/ApnTransport.php | 68 +++ server/src/Push/Transports/FcmTransport.php | 76 +++ server/src/Support/PushNotification.php | 152 ----- server/src/Support/Storefront.php | 3 +- server/src/routes.php | 8 +- .../CustomerDeviceRegistrationTest.php | 175 ++++++ .../NotificationChannelTestPushTest.php | 121 ++++ .../NotificationContractsTest.php | 509 ++--------------- server/tests/Unit/Push/PushLayerTest.php | 526 ++++++++++++++++++ translations/en-us.yaml | 13 + 42 files changed, 2299 insertions(+), 1861 deletions(-) create mode 100644 addon/components/modals/test-notification-channel.hbs create mode 100644 app/components/modals/test-notification-channel.js create mode 100644 server/src/Notifications/StorefrontOrderNotification.php create mode 100644 server/src/Push/ApnClientFactory.php create mode 100644 server/src/Push/Contracts/SendsPushNotification.php create mode 100644 server/src/Push/FirebaseMessagingFactory.php create mode 100644 server/src/Push/PushConfigurationException.php create mode 100644 server/src/Push/PushCredentialResolver.php create mode 100644 server/src/Push/PushMessage.php create mode 100644 server/src/Push/PushOutcome.php create mode 100644 server/src/Push/StorefrontPushChannel.php create mode 100644 server/src/Push/Transports/ApnTransport.php create mode 100644 server/src/Push/Transports/FcmTransport.php delete mode 100644 server/src/Support/PushNotification.php create mode 100644 server/tests/Unit/Http/Controllers/CustomerDeviceRegistrationTest.php create mode 100644 server/tests/Unit/Http/Controllers/NotificationChannelTestPushTest.php create mode 100644 server/tests/Unit/Push/PushLayerTest.php diff --git a/addon/components/modals/create-notification-channel.hbs b/addon/components/modals/create-notification-channel.hbs index be48cf72..59e63251 100644 --- a/addon/components/modals/create-notification-channel.hbs +++ b/addon/components/modals/create-notification-channel.hbs @@ -34,6 +34,20 @@
+ {{else if (eq key "environment")}} + + + {{else if (or (eq key "private_key_content") (eq key "firebase_credentials_json"))}}