OneSignal-Website-SDK
OneSignal-Website-SDK copied to clipboard
[Question]: Should the Launch URL setting work in iOs PWA Notifications?
How can we help?
Hi, I am integrating a simple OneSignal setup to use Android and iOs PWA Push Notifications using the custom code approach. When I send Notifications manually then the notification is shown correctly, but the launch URL parameter is being ignored on iOs, Android works correctly.
The current setup looks like this:
- We also use a minimal Workbox Service Worker setup for a positive Offline response and integrate it in the
OneSignalSDKWorker.jsfile:
importScripts("/sw.js?v=1");
importScripts("https://cdn.onesignal.com/sdks/OneSignalSDKWorker.js");
- The
OneSignal.initlooks like this:
window.addEventListener("load", () => {
if ("serviceWorker" in navigator) {
navigator.serviceWorker
.register("/OneSignalSDKWorker.js")
.catch((error) => {
console.warn("Error registering service worker:");
console.warn(error);
});
}
});
// Wait for domloaded
window.addEventListener("DOMContentLoaded", () => {
// Check if the app runs in installed mode, or at least not in default browser mode
if (!window.matchMedia("(display-mode: browser)").matches) {
window.OneSignal = window.OneSignal || [];
OneSignal.push(function () {
OneSignal.init({
appId: "...",
safari_web_id: "...",
welcomeNotification: {
title: "Some Title",
message: "Some message",
},
promptOptions: {
slidedown: {
prompts: [
{
type: "push",
autoPrompt: true,
text: {
actionMessage: "Some Message",
acceptButton: "yes",
cancelButton: "no",
},
delay: {
pageViews: 1,
timeDelay: 10,
},
},
],
},
},
});
});
}
});
Is the setup wrong or is it currently not supposed to be possible to open an URL in an installed iOs PWA?
Thank you for your feedback.
Would it be possible to workaround the issue with Event Listeners or something similar? The ones I've identified so far in Web SDK are marked to not work on safari. Or should the feature work but my setup is messed up, thank you for your time.
I got around this using Event listeners for the 'notificationClicked' event from memory and it works in Safari as well as the other browsers. Have you tried this yet?