Azure blob 静态网站上的网络通知

web notification on azure blob static website

我有一个使用 Azure 存储的静态网站:

https://helloweb.blob.core.windows.net/content/index.html

我需要在 onesiganl 应用程序设置中配置的域是什么:

站点URLhttps://helloweb.blob.core.windows.net

默认通知图标 URL: https://helloweb.blob.core.windows.net/content/icon.png

我的manifest.json:

{
  "name": "Hello Web",
  "short_name": "Helloweb",
  "start_url": "/content/index.html",
  "display": "standalone",
  "gcm_sender_id": "482941778795"
}

I can't see any user at onesignal users page.

根据 onesignal document 提到 OneSignalSDKWorker.js & OneSignalSDKUpdaterWorker.js 应该从 top-level根。 在 Azure 存储中,我们无法top-level root 中设置 blob。 blob 需要一个容器。

Upload the files to the top-level root of your site directory. The following URLs should be publicly accessible:

https://yoursite.com/manifest.json

https://yoursite.com/OneSignalSDKWorker.js

https://yoursite.com/OneSignalSDKUpdaterWorker.js

OneSignalSDKWorker.js & OneSignalSDKUpdaterWorker.js

• These files should not be renamed and the files should be served from the top-level root

根据我的经验,将网站放在 Azure 存储中并不是一个好的选择。我们可以使用 azure WebApp service 轻松做到这一点。我为它做一个测试。它工作正常。

以下是我的详细步骤:

1.Create 来自 Azure 门户的 WebApp

2.Configure OnSignal 设置

3.Download Web Push SDK and follow the tutorials 编辑清单文件。

4.Add一个索引文件,只需要替换"YOUR APP ID"

  <head>
      <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: "YOUR_APP_ID",
          autoRegister: false,
          notifyButton: {
            enable: true /* Set to false to hide */
          }
        }]);
      </script>
    </head>

5.Upload 使用 Kudu 将代码放入 WebApp (https://yoursite.scm.azurewebsite.net/).We can drag files into the folder directly. More deploy please refer to official document.

  1. 从 Firefox 浏览器访问 https://yoursite.azurewebsite.net/index.html。并且我们需要设置权限来设置消息弹窗。

  1. 从[所有用户]查看我们将看到订阅的用户信息