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

[Question]: Should the Launch URL setting work in iOs PWA Notifications? #1044

Open
Reizoukodesu opened this issue May 24, 2023 · 2 comments

Comments

@Reizoukodesu
Copy link

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.js file:
importScripts("/sw.js?v=1");
importScripts("https://cdn.onesignal.com/sdks/OneSignalSDKWorker.js");
  • The OneSignal.init looks 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.

@Reizoukodesu
Copy link
Author

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.

@rhurlbatt
Copy link

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?

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

No branches or pull requests

2 participants