-
Notifications
You must be signed in to change notification settings - Fork 17
Fix crashes on macOS High Sierra #18
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
Conversation
This enables API warnings
…ionsManager GHDesktopNotificationsManager is now available only on macOS 10.14 and later.
// Only macOS 10.14 and newer are supported. Since os.release() gives us the | ||
// Darwin kernel version, it should be a major version of 18 or higher, according | ||
// to https://en.wikipedia.org/wiki/Darwin_%28operating_system%29#Release_history | ||
return majorVersion >= 18 |
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.
I saw on Desktop we use Electron's process.getSystemVersion()
instead, but that's not available here. Not sure if there is an alternative to this, but I didn't want to add new dependencies and seems like this check should be reliable enough 🤞
// Create the desktop notifications manager only if it's a supported macOS version | ||
if (@available(macOS 10.14, *)) | ||
{ | ||
desktopNotificationsManager = [GHDesktopNotificationsManager new]; | ||
} | ||
else | ||
{ | ||
return env.Undefined(); | ||
} |
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.
I can't do a if (!@available(...)) { return }
because the compiler is not smart enough to understand everything outside the if
is safe for 10.14
🤦
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.
✨ Makes sense.
(From what I understood from reading fairly foreign syntax to me - but seems there is the check for mac, if good, instantiate a manager. Then, if there is manager, let it handle showing notifications work.)
Exactly that, thanks for the quick review! ❤️ |
As an attempt to fix desktop/desktop#14712 this PR encapsulates all usages of the Notifications API inside of
GHDesktopNotificationsManager
, which is now used only on macOS 10.14 and newer.I also switched the deployment target to 10.13, in order to get warnings on build time when unavailable APIs are being used.