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
@sgammon
Copy link
Author

sgammon commented Nov 25, 2024

this needs a rebase but otherwise it is close to being done. there also need to be methods to trigger a request for notification permissions, which is required on platforms like iOS and Android.

windows notification service ("WNS") will probably remain experimental for now

Copy link
Contributor

Package Changes Through d368d87

There are 7 changes which include tauri-bundler with minor, tauri-cli with minor, @tauri-apps/cli with minor, tauri with minor, tauri-runtime with minor, tauri-runtime-wry with minor, tauri-utils with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
tauri-utils 2.1.0 2.1.1
tauri-bundler 2.1.0 2.2.0
tauri-runtime 2.2.0 2.3.0
tauri-runtime-wry 2.2.0 2.3.0
tauri-codegen 2.0.3 2.0.4
tauri-macros 2.0.3 2.0.4
tauri-plugin 2.0.3 2.0.4
tauri-build 2.0.3 2.0.4
tauri 2.1.1 2.2.0
@tauri-apps/cli 2.1.0 2.2.0
tauri-cli 2.1.0 2.2.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

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