用于 Tizen 可穿戴 Web 应用程序的 FCM
FCM for Tizen Werable Web Application
我正在开发 Tizen 可穿戴 独立 Web 应用程序,并希望集成 Firebase 以合并通知功能。我使用 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 需要 service worker 支持。
您可以尝试这个简单的代码片段来检查服务工作者支持。
if ('serviceWorker' in navigator)
alert('Service worker is Supported');
else
alert('Service worker is not Supported');
我已经在 Firefox 上试过代码片段,Chrome
(快捷方式:开发者工具 > 控制台 > 粘贴代码 > 回车)。
两者都支持服务工作者。但是,当我在 Tizen Web 应用程序的 js 文件中添加此代码块时,它会提示 'not supported'.
在 Google 开发人员上注册服务工作者的代码示例还包括此检查服务工作者 API 在注册之前首先可用性。
关于本机移动环境而不是 Web,FCM 支持 Android 和 iOS 本机环境,但不支持 Tizen Native。
我正在开发 Tizen 可穿戴 独立 Web 应用程序,并希望集成 Firebase 以合并通知功能。我使用 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 需要 service worker 支持。
您可以尝试这个简单的代码片段来检查服务工作者支持。
if ('serviceWorker' in navigator)
alert('Service worker is Supported');
else
alert('Service worker is not Supported');
我已经在 Firefox 上试过代码片段,Chrome (快捷方式:开发者工具 > 控制台 > 粘贴代码 > 回车)。
两者都支持服务工作者。但是,当我在 Tizen Web 应用程序的 js 文件中添加此代码块时,它会提示 'not supported'.
在 Google 开发人员上注册服务工作者的代码示例还包括此检查服务工作者 API 在注册之前首先可用性。
关于本机移动环境而不是 Web,FCM 支持 Android 和 iOS 本机环境,但不支持 Tizen Native。