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): push notifications #1015

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

Conversation

sgammon
Copy link

@sgammon sgammon commented Nov 12, 2024

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:

- 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]>
Copy link
Contributor

github-actions bot commented Nov 12, 2024

Package Changes Through 79cae51

There are 1 changes which include tao with minor

Planned Package Versions

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

package current next
tao 0.30.8 0.31.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

Comment on lines +148 to +157
/// ## 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),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs guard

Copy link
Member

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"

Copy link
Author

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.

Comment on lines +240 to +241
PushRegistration(token) => Some(PushRegistration(token)),
PushRegistrationError(error) => Some(PushRegistrationError(error)),
Copy link
Author

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

Comment on lines +70 to +77
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),
);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guards

Comment on lines 420 to 426
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)));
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guards

@sgammon
Copy link
Author

sgammon commented Nov 16, 2024

@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]>
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