-
-
Notifications
You must be signed in to change notification settings - Fork 197
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): push notifications #1015
base: dev
Are you sure you want to change the base?
Conversation
- feat(apns): add responders and events for APNS registration and error callbacks - feat(apns): call `registerForRemoteNotifications` within `did_finish_launching` - feat(apns): dispatch event to app for apns registration - feat(apns): gate push notifications behind `push-notifications` feature Relates-To: tauri-apps/tauri#11651 Signed-off-by: Sam Gammon <[email protected]>
Signed-off-by: Sam Gammon <[email protected]>
Package Changes Through 79cae51There are 1 changes which include tao with minor Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
/// ## Push Tokens | ||
/// | ||
/// Emitted when registration completes and an application push token is made available; on Apple | ||
/// platforms, this is the APNS token. On Android, this is the FCM token. | ||
PushRegistration(PushToken), | ||
|
||
/// ## Push Token Errors | ||
/// | ||
/// Emitted when push token registration fails. | ||
PushRegistrationError(String), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs guard
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what you mean by "needs guard"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amrbashir these are my own comments to remind myself to add #[cfg(feature = "push-notifications")
so that this code isn't included unless developers opt-in.
PushRegistration(token) => Some(PushRegistration(token)), | ||
PushRegistrationError(error) => Some(PushRegistrationError(error)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these need guards as well
decl.add_method( | ||
sel!(application:didRegisterForRemoteNotificationsWithDeviceToken:), | ||
did_register_for_apns as extern "C" fn(&Object, Sel, id, id), | ||
); | ||
decl.add_method( | ||
sel!(application:didFailToRegisterForRemoteNotificationsWithError:), | ||
did_fail_to_register_for_apns as extern "C" fn(&Object, _: Sel, id, id), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guards
src/platform_impl/macos/app_state.rs
Outdated
pub fn did_register_push_token(token_data: Vec<u8>) { | ||
HANDLER.handle_nonuser_event(EventWrapper::StaticEvent(Event::PushRegistration(token_data))); | ||
} | ||
|
||
pub fn did_fail_to_register_push_token(err: String) { | ||
HANDLER.handle_nonuser_event(EventWrapper::StaticEvent(Event::PushRegistrationError(err))); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guards
Signed-off-by: Sam Gammon <[email protected]>
@amrbashir could i get a workflow run? i'm curious how this does in ci. i think it should pass |
Signed-off-by: Sam Gammon <[email protected]>
Signed-off-by: Sam Gammon <[email protected]>
Summary
Part 1 of a 3 part proposal for Push Notifications support in Tauri; this includes support in Tao for
AppDelegate
methods needed for APNS registration on macOS and iOS.Part of tauri-apps/tauri#11651.
Please see the PR to Tauri for a full description: