uPaymeiFixit
uPaymeiFixit

Reputation: 343

OneSignal hello-world webpage - no notification

I've spent an embarrassingly long time on this seemingly incredibly easy problem with 0 progress. I'm pretty desperate at this point, so if anybody could review the short example I've written, I would greatly appreciate it.

What I'm trying to do: send a push notification using OneSignal's Web Push SDK.

Files in ~/Desktop/OneSignal-Browser-Example:

index.html

<head>
    <title>OneSignal Example</title>
    <link rel="manifest" href="/manifest.json">
    <script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async></script>
    <script>
        var OneSignal = window.OneSignal || [];
        OneSignal.push(["init", {
          appId: "518e60ef-8b73-4852-8172-61cb170dce00",
          autoRegister: true,
          notifyButton: {
            enable: true /* Set to false to hide */
          }
        }]);
        console.log("Test");
    </script>
    <h1>LOADED</h1>
</head>

manifest.json

{
  "name": "OneSignal Example",
  "short_name": "OneSignalExample",
  "start_url": "/",
  "display": "standalone",
  "gcm_sender_id": "482941778795"
}

OneSignalSDKWorker.js

importScripts('https://cdn.onesignal.com/sdks/OneSignalSDK.js');

OneSignalSDKUpdaterWorker.js

importScripts('https://cdn.onesignal.com/sdks/OneSignalSDK.js');

cert.pem

key.pem

I launched Google Chrome with /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --ignore-certificate-errors, and set up a https server on port 8081 with http-server --ssl --p 8081 ~/Desktop/OneSignal-Browser-Example.

Attached is a screenshot of the trace log.

trace log image

Upvotes: 0

Views: 648

Answers (1)

Jason
Jason

Reputation: 6926

I think we were able to help you out over our support channel to solve the issue.

The issue was a specific configuration mismatch: uPaymeiFixit had modified the manifest.json file's gcm_sender_id property to an incorrect value; he subscribed after this change and registered his user with a mismatched GCM Sender ID which prevented notifications from being able to send even though everything else was correct.

The solution to this issue was to:

  1. Correct the gcm_sender_id value.
  2. Reset his site data and cache to test again as a new user.

He was able to receive a notification right after these changes.

Upvotes: 1

Related Questions