fix: keep APNs token events opt-in - #21
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The opt-in behavior is applied on iOS but macOS still emits push-token unconditionally, which conflicts with the stated cross-Apple-platform APNs token exposure goal.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR introduces a compatibility switch to keep the APNs token available via the awaited push registration call while making the legacy push-token renderer event opt-in (intended to reduce default exposure of raw APNs credentials to the renderer).
Changes:
- Add
exposePushTokenEvents/expose_push_token_eventsconfig flag (defaultfalse) to control whether thepush-tokenevent is emitted. - Gate iOS
push-tokenevent emission behind that flag and add Swift decoding tests for the new config key. - Document the new compatibility switch in the API docs.
File summaries
| File | Description |
|---|---|
src/lib.rs |
Adds a new plugin config boolean for opting into push-token event emission. |
README.md |
Documents the iOS compatibility switch for legacy push-token events. |
ios/Tests/PluginTests/PluginTests.swift |
Adds Swift decoding coverage for the new config option. |
ios/Sources/NotificationPlugin.swift |
Parses the new config key and stores it on the plugin instance. |
ios/Sources/AppDelegateSwizzler.swift |
Conditionally emits push-token based on the opt-in flag. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| AppDelegateSwizzler.plugin?.handlePushTokenReceived(hex) | ||
| try? AppDelegateSwizzler.plugin?.trigger("push-token", data: ["token": hex]) | ||
| if AppDelegateSwizzler.plugin?.exposePushTokenEvents == true { | ||
| try? AppDelegateSwizzler.plugin?.trigger("push-token", data: ["token": hex]) | ||
| } |
| On iOS the APNs token is returned to the caller but is not also emitted through | ||
| the generic Tauri event channel by default. Apps that intentionally handle the | ||
| raw token in JavaScript can opt into the legacy `push-token` event in | ||
| `tauri.conf.json`: |
|
Closing at the Charm maintainer request. No further changes will be proposed from this work. |
Summary
push-tokenrenderer event opt-inSecurity and compatibility
The default now keeps raw APNs credentials outside the renderer event boundary. Existing JavaScript consumers can preserve the legacy event with
plugins.notifications.exposePushTokenEvents: true.Provenance and audit
758156fd9b1cbc99c83062194a2a59c411b5907f(currentmainon 2026-09-05)Verification
cargo fmt --all -- --check