OneSignal / OneSignal-Website-SDK

OneSignal is a push notification service for web and mobile apps. This SDK makes it easy to integrate your website with OneSignal Push Notifications. https://onesignal.com
Other
383 stars 114 forks source link

[Bug]: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'message') #1106

Open ndarproj opened 10 months ago

ndarproj commented 10 months ago

What happened?

I am using the latest version of laravel which is Laravel v10.24.0 (PHP v8.1.10) and i am getting an error

i have this code on head

    <script src="https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.js" defer></script>
    <script>
        window.OneSignalDeferred = window.OneSignalDeferred || [];
        OneSignalDeferred.push(function(OneSignal) {
            OneSignal.init({
                appId: "d7c7e6bb-81a3-4d18-90b8-e99ffb3d3b4f",
            });
        });
    </script>

onesignal2 onesignal

What browsers are you seeing the problem on?

Firefox, Chrome (Chromium), Brave

What operating system are you running?

Windows 10

Steps to reproduce?

1. Setup Web Platform w/ localhost:8000 as site url
2. Run Laravel php artisan serve
3. Go to localhost:8000

What did you expect to happen?

The notification bell button would appear on my lower left corner

Relevant log output

No response

jkasten2 commented 10 months ago

@ndarproj Thanks for reporting. The error isn't clear here but this due to the v16 SDK no longer supporting sites that are HTTP or use the os.tc domain. This change is part of the v16 release notes release notes. You will need configure OneSignal to use your own HTTPS domain on the dashboard to switch to the OneSignal v16 SDK.

We will be making an update to the OneSignal SDK to provide a better error to make this requirement more clear.

CropWatchDevelopment commented 10 months ago

My website is HTTPS hosted on Vercel and I am getting this same exact error as well.

softwareonair commented 10 months ago

I'm trying to debug my app on the localhost. since v16 requires https domain, how should we work on the localhost?

i have followed the local testing instructions on documentation btw

jkasten2 commented 10 months ago

@softwareonair You can enable the "LOCAL TESTING" when you use a url that start with http://localhost.

image

Note that http is limited to localhost as a secure context is required for service workers which is required for push. If you need to test a different URL it must start with https://

jesobreira commented 9 months ago

I was facing this issue on a domain that uses HTTPS (in production)...

It seems we must disable the os.tc feature in the app config and rename OneSignalSDK.sw.js to OneSignalSDKWorker.js.

It seems that the docs are too outdated or misleading...