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: Enable APNS registration + notification delivery in macOS apps #33574
Conversation
We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix. Examples of commit messages with semantic prefixes:
Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
shell/browser/browser_mac.mm
Outdated
@@ -532,4 +532,34 @@ void RemoveFromLoginItems() { | |||
} | |||
} | |||
|
|||
void Browser::RegisterForRemoteNotifications() { | |||
[[AtomApplication sharedApplication] | |||
registerForRemoteNotificationTypes:NSRemoteNotificationTypeBadge | |
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.
Attempting to use the updated API (registerForRemoteNotifications) resulted in this error:
'registerForRemoteNotifications' has been marked as being introduced in macOS 10.14 here, but the deployment target is macOS 10.11.0
@zcbenz thanks so much for the review! Is there any guidance on next steps to get this merged? |
We just need to wait for a few more reviews from maintainers. |
cc @miniak and @MarshallOfSound who have worked in this area previously |
Hey |
Haven't had a chance to look this over yet but I don't see CI runs this PR yet. @joanx can you try signing in to circleci and pushing a new commit to this PR. Builds should kick off after that |
@MarshallOfSound just did! |
Few things:
I'm not a fan of lumping everything in with
I'm open to arguments for either or an alternative, but I'm -0.5 on lumping this into |
@MarshallOfSound , thanks for the review. I'm unfortunately not familiar with the code organization and languages used here and unable to achieve a working binary with the refactor though I'd hugely appreciate any guidance on the in-progress changes. Wondering if you have thoughts on any of these options:
Thank you! |
Hi @nornagon, could this PR move forward? |
@tiagoporto there's still a bit of outstanding code review I'm hoping to get to shortly! |
Hi @nornagon , thanks so much for the review. I believe I've addressed the comments, though am seeing some build failures that I'm not sure are related to my changes; would love any guidance. thanks! edit: build is green now |
Overall looking pretty good! Now that I'm looking more closely at the API, I think the registerForAPNSNotifications
function might be better expressed as a Promise, rather than as a function which returns void and triggers one of two events later on. It might be a little trickier to implement in the C++ side, though.
Updated to promisify APNS registration method, and tested here |
awesome awesome. did you happen to check how macOS behaves if you call registerForAPNSNotifications()
twice?
e.g. does this work with the new code?
const token1 = await pushNotifications.registerForAPNSNotifications()
const token2 = await pushNotifications.registerForAPNSNotifications()
does the 2nd promise properly resolve (or reject)? i.e. is it not left hanging forever? Also, is the token returned the same?
[edit] confirmed out-of-band that the above works as expected :)
Updated + re-tested! |
Great job @joanx , looking forward to this merge. |
Congrats on merging your first pull request! |
Release Notes Persisted
|
Could this be backported to v20? |
@KishanBagaria Unfortunately, we generally don't backport features to older branches at this point of the release cycle. For more information on the process: https://github.com/electron/governance/blob/main/wg-releases/feature-backport-requests.md |
Description of Change
Want to pick up on previous attempts #13777 and #18286 by @frantic and @kevinhu88 to enable APNS in Electron.
My understanding is that #18286 was blocked on concerns over supporting
UserNotification
andNSUserNotifications
at the same time. This subset (APNS registration + notification receipt) doesn't actually seem to reference theUserNotification
object (the relevantUserNotification
-related code appears to have been handled in @miniak 's #25950.)I've ported over the remaining functionality to register + receive APNS notifications into a separate fork (as the previous PR appears to be blocked on merge conflicts) and have confirmed successful registration + notification receipt via APNs with this sample app using Apple's command-line tools (note, I needed to create a provisioning profile + code-sign this app for successful APNS registration).
Would love to re-start the conversation around what it would take to enable APNS in Electron. Thanks in advance!
Checklist
npm test
passesRelease Notes
Notes: Added support for push notifications from APNs for macOS apps.