问题描述
我正在通过Web应用程序通过仓库发送fcm警报。
firebase_admin.exceptions.InvalidArgumentError: The registration token is not a valid FCM registration token
但是我一直收到这种错误。
def send_pushserver():
# This registration token comes from the client FCM SDKs.
registration_token = 'KEY'
# See documentation on defining a message payload.
message = messaging.Message(
notification=messaging.Notification(
title='Hi',body='Message',),token=registration_token,)
response = messaging.send(message)
# Response is a message ID string.
print('Successfully sent message:',response)
发送通知的代码部分。 “ registration_token”包含Web推送证书的密钥对。
<html>
<div class="demo-layout mdl-layout mdl-js-layout mdl-layout--fixed-header">
<main class="mdl-layout__content mdl-color--grey-200">
<div class="mdl-cell mdl-cell--12-col mdl-cell--12-col-tablet mdl-grid">
<div class="mdl-card mdl-shadow--2dp mdl-cell mdl-cell--12-col mdl-cell--12-col-tablet mdl-cell--12-col-desktop">
<div id="messages">
</div>
</div>
</div>
</main>
</div>
<script>
importScripts('https://www.gstatic.com/firebasejs/8.0.0/firebase-app.js')
importScripts('https://www.gstatic.com/firebasejs/8.0.0/firebase-analytics.js')
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later,measurementId is optional
var firebaseConfig = {
apiKey: "",authDomain: "",databaseURL: "",projectId: "",storageBucket: "",messagingSenderId: "",appId: "",measurementId: ""
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
//firebase.analytics();
const messaging = firebase.messaging();
messaging.onMessage((payload) => {
console.log('Message received. ',payload);
appendMessage(payload);
});
function appendMessage(payload) {
showToken(payload);
const messagesElement = document.querySelector('#messages');
const dataHeaderElement = document.createElement('h5');
const dataElement = document.createElement('pre');
dataElement.style = 'overflow-x:hidden;';
dataHeaderElement.textContent = 'Received message:';
dataElement.textContent = JSON.stringify(payload,null,2);
messagesElement.appendChild(dataHeaderElement);
messagesElement.appendChild(dataElement);
}
</script>
</html>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)