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

Feat/safari vapid #1002

Merged
merged 12 commits into from
Mar 13, 2023
Merged

Feat/safari vapid #1002

merged 12 commits into from
Mar 13, 2023

Conversation

jkasten2
Copy link
Member

@jkasten2 jkasten2 commented Mar 9, 2023

Description

One Line Summary

Add support for Safari browsers that only support the VAPID PushAPI (iOS), Legacy Safari push will continue to be preferred where it is available (macOS).

Details

Validation

Tests

macOS 13.1 with Safari 16.2

  • Subscribed with Safari Legacy APIs and it receives notifications
  • Tested with window.safari = undefined to simulate an iOS WebApp env, ensured it used VAPID push and received pushes
  • Tested with delete PushSubscriptionOptions to simulate Safari on pre-macOS13, ensured it subscribed and received notifications

iOS 16.4 beta 3

  • SDK didn't prompt until it was A2HS, as expected.
  • Notification prompting worked and notification was received.

macOS 12.6.3 with Safari 15.6.1

  • Prompted and notification received

Windows 11 22H2 Chrome 110.0.5481.105

  • Prompted and notification received

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

Due to Safari on macOS 13+ bugs we are holding off on PR #930, which attempted to use VAPID by default and migrate existing Legacy Safari players to it.

This also resolves issue "Chrome Desktop with Dev iOS View - TypeError: Cannot read property 'pushNotification' of undefined" #560


This change is Reviewable

Copy link
Contributor

@rgomezp rgomezp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one comment, otherwise LGTM

express_webpack/index.html Outdated Show resolved Hide resolved
corrected types and names based on Apple's docs and confirmed with
testing
This clears up any confusion between the two Safari enums.
Add global methods other parts of the SDK an use to know which Push
JS API should be used for Safari.
These will allow use to easily change the logic later if we want to
prefer VAPID over the window.safari API later.
Use the new "use*" Safari functions we added in the last commit to
select the delivery platform.

For context, this maps to player.device_type when a network call is made
as well as few other parts of the SDK.
This isn't a substitute for testing on iOS, but this can help improve
development speed as tweaks can be made faster.
window is not available in a ServiceWorker context. Also Legacy push API
is not available in the ServiceWorker context anyway.
@jkasten2 jkasten2 merged commit d393cac into main Mar 13, 2023
@jkasten2 jkasten2 deleted the feat/safari-vapid branch March 13, 2023 20:04
@jkasten2 jkasten2 mentioned this pull request Mar 13, 2023
jkasten2 added a commit that referenced this pull request Jul 26, 2023
Corrected missing logic changes that PR #1002 introduced in main but
were not accounted for in the last rebase.

Tested on masOS 13.3.1 with Safari 16.4 to confirm the browser
subscribes to push correctly with the backend.
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.

2 participants