【问题标题】:OneSignal hello-world webpage - no notificationOneSignal hello-world 网页 - 无通知
【发布时间】:2017-01-30 09:07:54
【问题描述】:

我在这个看似非常简单的问题上花了很长时间,进度为 0。在这一点上我非常绝望,所以如果有人可以查看我写的简短示例,我将不胜感激。

我正在尝试做的事情:使用 OneSignal 的 Web 推送 SDK 发送推送通知。

~/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>

ma​​nifest.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

我用/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --ignore-certificate-errors启动了谷歌浏览器,并用http-server --ssl --p 8081 ~/Desktop/OneSignal-Browser-Example在端口8081上设置了一个https服务器。

附上跟踪日志的截图。

【问题讨论】:

    标签: javascript google-chrome ssl google-cloud-messaging onesignal


    【解决方案1】:

    我认为我们能够通过我们的支持渠道帮助您解决问题。

    问题是特定的配置不匹配:uPaymeiFixit 已将manifest.json 文件的gcm_sender_id 属性修改为不正确的值;他在此更改后订阅并使用不匹配的 GCM 发件人 ID 注册了他的用户,即使其他所有内容都正确,也无法发送通知。

    解决这个问题的方法是:

    1. Correct gcm_sender_id 值。
    2. Reset his site data and cache 以新用户身份再次测试。

    他能够在这些更改后立即收到通知。

    【讨论】:

    • #2 在这里很重要
    猜你喜欢
    • 2013-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-29
    • 2014-09-25
    • 2013-04-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多