Skip to content

Conversation

fadi-george
Copy link
Contributor

@fadi-george fadi-george commented Jul 9, 2025

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.

  • Removes all legacy safari notification logic
  • Adds porting logic in _updatePushSubscriptionModelWithRawSubscription to change from the old token format to the standard format
  • Add logic to save token and id in IndexedDB

Old Data:
Screenshot 2025-07-09 at 4 12 43 PM

New/Migrated Data:
Screenshot 2025-07-09 at 4 42 23 PM

Systems Affected

  • WebSDK
  • Backend
  • Dashboard

Validation

Tests

Info

Checklist

  • All the automated tests pass or I explained why that is not possible
  • I have personally tested this on my machine or explained why that is not possible
  • I have included test coverage for these changes or explained why they are not needed

Programming Checklist
Interfaces:

  • Don't use default export
  • New interfaces are in model files

Functions:

  • Don't use default export
  • All function signatures have return types
  • Helpers should not access any data but rather be given the data to operate on.

Typescript:

  • No Typescript warnings
  • Avoid silencing null/undefined warnings with the exclamation point

Other:

  • Iteration: refrain from using elem of array syntax. Prefer forEach or use map
  • Avoid using global OneSignal accessor for context if possible. Instead, we can pass it to function/constructor so that we don't call OneSignal.context

Screenshots

Info

Checklist

  • I have included screenshots/recordings of the intended results or explained why they are not needed

Related Tickets



This change is Reviewable

@fadi-george fadi-george force-pushed the fg/remove-safari branch 2 times, most recently from 5f389cd to 6ef93e3 Compare July 10, 2025 01:41
Copy link
Contributor

@sherwinski sherwinski left a 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'),
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@sherwinski
Copy link
Contributor

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.

Comment on lines -60 to -61
return window.safari.pushNotification.permission(safariWebId)
.permission as NotificationPermission;
Copy link
Member

@jkasten2 jkasten2 Jul 10, 2025

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

@fadi-george
Copy link
Contributor Author

I think one option to push a breaking change v17 and remove the remaining legacy safari specific code.

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.

3 participants