Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: push notifications #11652

Draft
wants to merge 9 commits into
base: dev
Choose a base branch
from
Draft

feat: push notifications #11652

wants to merge 9 commits into from

Conversation

sgammon
Copy link

@sgammon sgammon commented Nov 12, 2024

Summary

Adds initial support wiring for Push Notifications (see: #11651).

This requires instrumentation down into tao, to call methods on the AppDelegate or NSApplication / UIApplication (for Apple platforms). Firebase Messaging (FCM) support is also under consideration.

  • tauri: Handle new events
    • (that's this pr)
    • Forward/map PushRegistration event
    • Forward/map PushRegistrationFailed event
    • General cleanup (don't repeat typedefs, etc)
  • tao: Hooks into UIApplication / NSApplication
  • tauri-plugin-push-notifications:
  • tauri-docs
  • Platform support
    • macOS (APNS)
    • iOS (APNS)
    • Windows (WNS)
    • Android (FCM)

PR Tree

This PR is accompanied by a plugin, tauri-plugin-push-notifications, and a PR to tao:

Known Issues

  • General
    • Token needs strong typing in guest code
  • Docs
    • macOS and iOS devices need an entitlement, which should be mentioned in the docs.
  • Tests
    • There are no tests yet.

Warning

This functionality is experimental and is gated behind the push-notifications feature for now.

How it works

(1) tao and tauri forward two new events: PushRegistration(PushToken) and PushRegistrationFailed(Error).
(2) a new plugin, tauri-plugin-push-notifications, listens for these events, holds the token or error, and exposes those values to guest code when requested.

sequenceDiagram
    tao->>+OS: Setup app delegate
    OS->>+tao: applicationDidFinishLaunching
    tao->>+OS: registerForRemoteNotifications()
    OS->>+tao: didFinishRegisteringWithToken()
    tao->>+tauri: PushRegistration(PushToken) Event
    tauri->>+Plugin: Forward event
    Plugin->>+Plugin: Retain token in-memory
    tauri->>+App: Launch app
    App<<->>+Plugin: await pushToken()
Loading

- feat(push): relay events for push notifications registration and
  errors to app
- feat(push): gate apns by `push-notifications` feature

Relates-To: tauri-apps#11651
Signed-off-by: Sam Gammon <[email protected]>
Signed-off-by: Sam Gammon <[email protected]>
Signed-off-by: Sam Gammon <[email protected]>
Signed-off-by: Sam Gammon <[email protected]>
Signed-off-by: Sam Gammon <[email protected]>
Signed-off-by: Sam Gammon <[email protected]>
Signed-off-by: Sam Gammon <[email protected]>
@ChrisCates
Copy link

Any way I can help ship this?
That or, what's your ETA for completion brotha?

@sgammon
Copy link
Author

sgammon commented Nov 17, 2024

@ChrisCates Very close to completion, i'm testing on macOS shortly. I haven't explored Android yet, so some research there might help (how best to integrate Firebase Cloud Messaging - FCM - into tao and tauri; ideally it could work within the plugin only).

Windows is looking solid but I'm not sure how to extract the token yet. That may remain experimental until later if only because I can't find any third party push services that support WNS at this time.

tl;dr I'd say we could get macOS and potentially iOS working within a few days. Android and WNS are probably easier/less complex, but may take a few days longer for research about how best to integrate. Regarding review and merge, I've no clue, this is my first PR to Tauri.

sgammon added a commit to sgammon/tauri-docs that referenced this pull request Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants