-
Notifications
You must be signed in to change notification settings - Fork 114
Have Safari use Standard Web Notifications #1329
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
base: main
Are you sure you want to change the base?
Conversation
5f389cd
to
6ef93e3
Compare
6ef93e3
to
d3f2407
Compare
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.
Overall the code looks good to me but I think we should let @jkasten2 weigh in on this one in case there are extra considerations I might be missing.
@@ -4,7 +4,7 @@ import { defineConfig } from 'vitest/config'; | |||
export default defineConfig({ | |||
define: { | |||
__API_ORIGIN__: JSON.stringify('onesignal.com'), | |||
__API_TYPE__: JSON.stringify('staging'), | |||
__API_TYPE__: JSON.stringify('production'), |
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.
what's the purpose of this change?
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.
This is just for the tests and will affect the api url is. It doesnt matter too much in this case since we use msw to mock the requests.
I think it would also be helpful to have some higher-level context on why we're making this change. If it's just because we don't need the legacy support anymore: i.e. any documentation online of when safari started supporting the web standard, usage metrics around legacy tokens, etc; things of that nature would help. |
return window.safari.pushNotification.permission(safariWebId) | ||
.permission as NotificationPermission; |
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.
We need to check if window.safari.pushNotification.permission(safariWebId)
returns false, and only then use the new VAPID push. This is due to a bug that still exists today in Safari that doesn't allow migrating someone who has accepted Safari legacy push for the domain to standard notifications.
See this Asana ticket for more details:
https://app.asana.com/1/780103692902078/project/1204295426001934/task/1204303093244836?focus=true
I think one option to push a breaking change v17 and remove the remaining legacy safari specific code. |
Description
1 Line Summary
Removes legacy safari notifications logic in favor of new standard web notifications.
Details
window.safari.pushNotification
was released in Safari 7 to allow push notifications for safari browsers. We added a lot of logic (now considered legacy) to have custom logic for chromium+firefox browsers and safari browsers. But since then Safari has pushed updates (v16+) to conform to standard window.Notifications api._updatePushSubscriptionModelWithRawSubscription
to change from the old token format to the standard formatOld Data:

New/Migrated Data:

Systems Affected
Validation
Tests
Info
Checklist
Programming Checklist
Interfaces:
Functions:
Typescript:
Other:
elem of array
syntax. PreferforEach
or usemap
context
if possible. Instead, we can pass it to function/constructor so that we don't callOneSignal.context
Screenshots
Info
Checklist
Related Tickets
This change is