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

fix: use a more unique identifier for NSUserNotification instances #17469

Merged
merged 1 commit into from Mar 20, 2019

Conversation

MarshallOfSound
Copy link
Member

Description of Change

So although apple has it documented that notifications with duplicate identifiers in the same session won't be presented. They apparently forgot to mention that macOS also non-deterministically and without any errors, logs or warnings will also not present some notifications in future sessions if they have a previously used identifier.

As such, we're going to truly randomize these identifiers so they are unique between apps and sessions. The identifier now consists of a randomly generated UUID and the app bundle id.

Release Notes

Notes: Fixed an issue where Notification objects constructed in the main process would randomly not be shown to the user.

So although apple has it documented that notifications with duplicate identifiers in the same session won't be presented.  They apparently forgot to mention that macOS also non-deterministically and without any errors, logs or warnings will also not present some notifications in future sessions if they have a previously used identifier.

As such, we're going to truly randomize these identifiers so they are
unique between apps and sessions.  The identifier now consists of a
randomly generated UUID and the app bundle id.
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Mar 19, 2019
@MarshallOfSound MarshallOfSound merged commit 45d90e7 into master Mar 20, 2019
@release-clerk
Copy link

release-clerk bot commented Mar 20, 2019

Release Notes Persisted

Fixed an issue where Notification objects constructed in the main process would randomly not be shown to the user.

@trop
Copy link
Contributor

trop bot commented Mar 20, 2019

I have automatically backported this PR to "3-1-x", please check out #17482

@trop
Copy link
Contributor

trop bot commented Mar 20, 2019

I have automatically backported this PR to "4-1-x", please check out #17483

@trop
Copy link
Contributor

trop bot commented Mar 20, 2019

I have automatically backported this PR to "5-0-x", please check out #17484

@sofianguy sofianguy added this to Fixed (3.1.7) in 3.0.x / 3.1.x Mar 25, 2019
@OrangeChu
Copy link

Thank you for your hard work.
I found that in some cases, Notification will not trigger click event. I didn't find the condition for recurrence. This is a random event. Is this maybe a bug?

@MarshallOfSound
Copy link
Member Author

@OrangeChu Your notification will be getting garbage collected. If you keep your notifications in a global store they won't be GC'ed and events will always fire 👍

E.g.

global.notifications = []
const n = new Notification({ title: 'x' })
n.on('click', console.info)
n.show()
global.notifications.push(n)

@OrangeChu
Copy link

@MarshallOfSound Thank you for your reply.
After testing, it was found that it was caused by the 'GC' recycling mechanism.
Sincere thanks! 😆

@sofianguy sofianguy added this to Fixed in 5.0.0-beta.7 in 5.0.x Mar 28, 2019
@sofianguy sofianguy added this to Fixed in 3.1.7 in 3.1.x Mar 29, 2019
kiku-jw pushed a commit to kiku-jw/electron that referenced this pull request May 16, 2019
…lectron#17469)

So although apple has it documented that notifications with duplicate identifiers in the same session won't be presented.  They apparently forgot to mention that macOS also non-deterministically and without any errors, logs or warnings will also not present some notifications in future sessions if they have a previously used identifier.

As such, we're going to truly randomize these identifiers so they are
unique between apps and sessions.  The identifier now consists of a
randomly generated UUID and the app bundle id.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-pr 🌱 PR opened in the last 24 hours
Projects
No open projects
3.0.x / 3.1.x
Fixed (3.1.7)
3.1.x
Fixed in 3.1.7
5.0.x
Fixed in 5.0.0-beta.7
Development

Successfully merging this pull request may close these issues.

None yet

4 participants