[英]FCM for Tizen Werable Web Application
我正在使用Tizen Wearable Standalone Web應用程序,並且想集成Firebase以合並Notifications Feature。 我使用Javascript遵循了Firebase提供的所有步驟。 但是我無法獲得令牌並最終出現以下錯誤:
Failed to register a ServiceWorker: The URL protocol of the current origin
('file://') is not supported."
code: "messaging/failed-serviceworker-registration"
message: "Messaging: We are unable to register the default service worker.
Failed to register a ServiceWorker: The URL protocol of the current origin
('file://') is not supported. (messaging/failed-serviceworker-
registration)."
stack: (...)
我試過了
navigator.serviceWorker.register('/sw.js').then(function(registration) {
console.log("success")
firebase.messaging().useServiceWorker(registration)
// Registration was successful
console.log('ServiceWorker registration successful with scope: ',registration.scope);
// registration.pushManager.subscribe({
console.log('Registration was successful1');
// userVisibleOnly: true
}).then(function(sub) {
console.log('endpoint:', sub.endpoint);
}).catch(function(e) {
console.log('Registration Failed',e);
});
但是無法使其正常工作。 請讓我知道FCM是否提供對Tizen Web應用程序的支持,因為我已經看到FCM提供程序已授予Android,iOS和Javascript訪問權限。 但是我從沒有看到對Tizen Web應用程序(可穿戴設備的混合應用程序)的支持。
Tizen Web應用程序不支持服務人員 。 FCM JavaScript API需要服務人員支持。
您可以嘗試使用此簡單的代碼片段來檢查服務人員的支持。
if ('serviceWorker' in navigator)
alert('Service worker is Supported');
else
alert('Service worker is not Supported');
我已經在Firefox,Chrome上嘗試過該代碼段(快捷方式:開發人員工具>控制台>粘貼代碼>輸入)。
兩者均支持服務人員。 但是,當我在Tizen Web應用程序的js文件上添加此代碼塊時,它會發出“不支持”的警報。
在Google開發人員上注冊服務工作者的代碼示例還包括在注冊之前首先檢查服務工作者API的可用性。
關於本機移動環境而不是Web,FCM支持Android和iOS本機環境,但不支持Tizen本機。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.