【发布时间】: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>
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
我用/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