feat: register native APNs/FCM device token on push.native (P2 push, slice 3a — mobile) - #8
Conversation
…slice 3a — mobile) Completes slice 3a's mobile half. When the daemon advertises push.native (transport native/relay — it sends via APNs/FCM directly), the client now registers this device's NATIVE push token (getDevicePushTokenAsync) instead of the Expo token. Expo transport (capability "push") is unchanged. - push-protocol.ts: PUSH_NATIVE_CAPABILITY = "push.native". - push.ts registerForPush: pick the token type by the advertised capability — native (raw APNs/FCM token, no EAS projectId) for push.native, Expo for push; register nothing if neither is advertised. Backward-compatible. Verified: tsc + eslint clean; expo export (web) bundles 1020 modules. Device e2e (real APNs/FCM delivery) needs a dev build + a daemon running transport native with your .p8 + Firebase creds. Signed-off-by: Yash Datta <saucam@gmail.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
There was a problem hiding this comment.
🔮 Oracle Review
🎯 Start Here
src/lib/push-protocol.ts (~20 min) — Security changes in push-protocol.ts
📋 PR Summary
What this PR does: Completes the mobile half of self-hosted native push by allowing clients to register raw APNs/FCM tokens when the daemon advertises the push.native capability.
Key changes:
- Added PUSH_NATIVE_CAPABILITY constant to the protocol shim.
- Implemented conditional token registration in registerForPush to select native tokens for push.native or Expo tokens for standard push.
- Maintained backward compatibility with existing Expo-based daemon configurations.
Areas affected: Push notification registration logic, Protocol definitions
Testing notes: Full end-to-end verification requires an EAS dev build and a daemon running with native transport configuration.
🔍 Code Review
This is a well-structured implementation that cleanly integrates native push support without disrupting existing Expo workflows. The capability-driven approach effectively abstracts the token selection logic, making the code easy to maintain and extend.
What's good:
- ✨ The capability-based routing logic is a strong pattern that ensures clear separation between protocol detection and implementation.
- ✨ Smart use of the protocol shim to decouple from the unreleased @codeoid/protocol package.
Generated by Oracle - Highflame's AI Code Reviewer
Address Oracle review on push.ts: getDevicePushTokenAsync().data is typed `any` via the ImplicitlySupportedDevicePushToken union arm (not `string`), so the runtime typeof coercion guarantees a string rather than assigning an `any` to `token: string`. Document why so it doesn't read as redundant. Signed-off-by: Yash Datta <saucam@gmail.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
What
Slice 3a — mobile half. Completes self-hosted native push: when the daemon advertises
push.native(itsnative/relaytransport sends via APNs/FCM directly — see codeoid #261), the client registers this device's native APNs/FCM token instead of an Expo token.Change
push-protocol.ts:PUSH_NATIVE_CAPABILITY = "push.native".push.tsregisterForPush: picks the token type by what the daemon advertises —push.native→getDevicePushTokenAsync()(raw APNs/FCM token; no EAS projectId needed),push→getExpoPushTokenAsync()(unchanged, slice 2),Backward-compatible: a daemon on Expo still advertises
push; a daemon onnative/relayadvertisespush.native. The registration wire message (push.register { token, platform }) is unchanged —platformalready tells the daemon/relay whether to send via APNs or FCM.Verification
tsc+eslintclean;expo export --platform webbundles 1020 modules. Device e2e (real APNs/FCM delivery + tap) needs an EAS dev build + a daemon runningtransport: nativewith your.p8+ Firebase service account — the one step that can't run headlessly.Follow-ups
push-protocol.tsshim and importpush.*+ capabilities from@codeoid/protocolonce a release ships them (both slices used the shim to decouple from the unreleased protocol).src/relayin codeoid) when the multi-user/hosted path is needed — mobile needs no further change (it already registers native tokens forrelaytoo).🤖 Generated with Claude Code