简体   繁体   English

Firebase 云消息传递 - JS SDK 中的 getToken() 错误

[英]Firebase Cloud Messaging - getToken() error in JS SDK

I am developing an app for KaiOS, a fork of the old Firefox OS, for which apps are based on HTML5 + JS.我正在为 KaiOS 开发一个应用程序,它是旧 Firefox 操作系统的一个分支,其应用程序基于 HTML5 + JS。 When compiling and running on device, Firebase Cloud Messaging stops working.在设备上编译和运行时,Firebase 云消息停止工作。 I receive an error as follows.我收到如下错误。

TypeError: 'applicationServerKey' member of PushSubscriptionOptionsInit could not be converted to any of: ArrayBufferView, ArrayBuffer. TypeError:PushSubscriptionOptionsInit 的“applicationServerKey”成员无法转换为以下任何一种:ArrayBufferView、ArrayBuffer。

I've followed the instructions in the Firebase docs here as well as this tutorial on setting up FCM for Progressive Web Apps here .我已按照此处Firebase 文档中的说明以及此处有关为渐进式 Web 应用程序设置 FCM 的教程进行操作。 I can confirm I am setting my key before calling getToken, as shown below:我可以在调用 getToken 之前确认我正在设置我的密钥,如下所示:

import firebase from "firebase";

const messaging = firebase.messaging();
messaging.usePublicVapidKey("<my-key-from-firebase-settings>");

messaging.getToken().then((currentToken) => {
    ...
}).catch((err) => {
    ...
});

I have searched for the above error, but to no avail.我已经搜索了上述错误,但无济于事。 Does anyone know what this error means or how to fix it?有谁知道这个错误是什么意思或如何解决? Running the application in the browser on my development machine, everything works perfectly.在我的开发机器上的浏览器中运行应用程序,一切正常。

Note: the app is written in Typescript Firebase SDK Version: 7.12.0注意:应用程序编写在 Typescript Firebase SDK 版本: 7.12.0

It might not be of help to you but I recently experienced a similar error message in a different environment:它可能对您没有帮助,但我最近在不同的环境中遇到了类似的错误消息:

Error: Failed to execute 'subscribe' on 'PushManager': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'错误:无法在“PushManager”上执行“订阅”:提供的值不是“(ArrayBuffer 或 ArrayBufferView)”类型

It was fixed in version 7.13.2 of Firebase:它已在 Firebase 的 7.13.2 版本中修复:

https://github.com/firebase/firebase-js-sdk/issues/2712 https://github.com/firebase/firebase-js-sdk/issues/2712

https://firebase.google.com/support/release-notes/js#version_7132_-_april_2_2020 https://firebase.google.com/support/release-notes/js#version_7132_-_april_2_2020

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Chrome扩展程序中Firebase Cloud Messaging的getToken()待处理 - Firebase Cloud Messaging's getToken() pending in Chrome Extension 每次刷新使用Firebase Cloud Messaging + React和firebase.messaging()。getToken()都是不同的 - Using Firebase Cloud Messaging + React and firebase.messaging().getToken() is different each refresh Firebase Cloud Messaging生成错误 - Firebase Cloud Messaging generating error Firebase Cloud Messaging 的 getToken() 仅在我省略 usePublicVapidKey 方法时才有效,为什么? - Firebase Cloud Messaging's getToken() only works if I omit the usePublicVapidKey method, why? firebase messenger.getToken() 返回 null - firebase messaging.getToken() return null Firebase云消息传递-调用firebase.messaging()时出错 - Firebase Cloud Messaging - Error calling firebase.messaging() 调用 firebase.messaging.getToken() 时出现“请求缺少身份验证凭据”错误 - "Request is missing authentication credential" error when calling firebase.messaging.getToken() 如何解决 React Native Firebase 错误 (messaging().getToken()),与 react-native-device-info 相关 - How to resolve React Native Firebase Error (messaging().getToken()), related to react-native-device-info Chrome上的Firebase Cloud Messaging未经授权错误401 - Firebase Cloud Messaging Unauthorized Error 401 on Chrome 用于 Firebase 消息传递的 Cloud Functions 中的负载错误 - Payload error in Cloud Functions for Firebase Messaging
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM