[英]Twilio "GCM/FCM unauthorized error: GCM/FCM API key is revoked or invalid" in conversations push notifications
I have implemented a simple chat using Twilio conversations API.我已经使用 Twilio 对话 API 实现了一个简单的聊天。 I'm following the doc for web push notifications ( https://www.twilio.com/docs/conversations/javascript/push-notifications-web ) and it's not clear to me what "FCM SECRET" I need to include in my Twilio Credential.
我正在关注网络推送通知的文档( https://www.twilio.com/docs/conversations/javascript/push-notifications-web ),我不清楚我需要在我的Twilio 凭证。 I have tried with my firebase app key pair (public and private) and also with firebase web API key, but in the Twilio logs I allways get a
GCM/FCM unauthorized error: GCM/FCM API key is revoked or invalid
error.我已经尝试使用我的 firebase 应用程序密钥对(公共和私有)以及 firebase Web API 密钥,但在 Twilio 日志中我总是收到
GCM/FCM unauthorized error: GCM/FCM API key is revoked or invalid
错误。
Update:更新:
My app code:我的应用程序代码:
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.8.2/firebase-app.js";
import { getMessaging, getToken, onMessage } from "https://www.gstatic.com/firebasejs/9.8.2/firebase-messaging.js";
const firebaseConfig = {
apiKey: "...",
authDomain: "...",
projectId: "...",
storageBucket: "...",
messagingSenderId: "...",
appId: "..."
};
const firebase = initializeApp(firebaseConfig);
const messaging = getMessaging(firebase);
const serviceWorkerRegistration = await navigator
.serviceWorker
.register('/js/firebase/firebase-messaging-sw.js');
if (firebase && messaging) {
// getting FCM token
getToken(messaging, {
vapidKey: '...',
serviceWorkerRegistration: serviceWorkerRegistration,
}).then(async (fcmToken) => {
console.log('token', fcmToken)
const conversationsClient = await getConversationsClient();
conversationsClient.setPushRegistrationId('fcm', fcmToken);
onMessage(messaging, payload => {
console.log('Message received. ', payload);
conversationsClient.handlePushNotification(payload);
});
}).catch((err) => {
console.log('Error getting token', err);
});
} else {
// no Firebase library imported or Firebase library wasn't correctly initialized
}
The fcmToken
is generated and successfuly registered in Twilio. fcmToken
在 Twilio 中生成并成功注册。
The Binding is created In Twilio with my credential referenced:绑定是在 Twilio 中创建的,并引用了我的凭据:
I believe the FCM Secret should be the apiKey
that you get when you register the web application and get the details like this:我相信 FCM Secret 应该是您在注册 Web 应用程序并获取如下详细信息时获得的
apiKey
:
You also need to ensure you are using that config when you initialize the Firebase SDK in your application.您还需要确保在应用程序中初始化 Firebase SDK 时使用该配置。
If you are using that config, then perhaps you can share the code that you are using in your app to initialize Firebase and request an fcmToken
from the user.如果您正在使用该配置,那么也许您可以共享您在应用程序中使用的代码来初始化 Firebase 并从用户那里请求一个
fcmToken
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.