messageaging.onMessage()中的payload.然后(function(payload)从fcm a



我在angularjs应用程序中使用fcm我可以连接到firebase并获得令牌,我可以在控制台中获得消息

>>firebaseDependencies: Object { app: {…}, appConfig: {…}, installations: {…}, … }
​
onMessageCallback: null
​
swRegistration: ServiceWorkerRegistration { installing: null, scope: "http://localhost:8080/firebase-cloud-messaging-push-scope", updateViaCache: "imports", … }
​
vapidKey: "BHlbwdTi9t_8-FMCh2X991P_KEuIsWMoKJSWYqk44B8AtWRhoehYpZ-GkHqnSfya9ANiTMLTUZxbpK1ASIgmLBc"
​
<prototype>: {…}
​​
app: 
​​
constructor: function rt(e)​​
deleteToken: function deleteToken()​​
getServiceWorkerRegistration: function getServiceWorkerRegistration()​​
getToken: function getToken()​​
logEvent: function logEvent(n, r)​​
messageEventListener: function messageEventListener(o)​​
onMessage: function onMessage(e)​​
onTokenRefresh: function onTokenRefresh()​​
requestPermission: function requestPermission()​​
setBackgroundMessageHandler: function setBackgroundMessageHandler()​​
usePublicVapidKey: function usePublicVapidKey(e)​​
useServiceWorker: function useServiceWorker(e)

我使用

>>https://fcm.googleapis.com/fcm/send
data
{
"to" : "dXECW-D1bx0GuaF6f-s0Ms:APA91bFjAL7-0WuqYuscLCRZJ0ojJqk1Qm8NLu21yNo8elXZy1VPzy5OGZhzRVkLTo7SSZgP9cjdx-Xq_c2jqgs2O73tYEUmfGuhflNbcq-aEVoTX4JslM1slgdQJSLvf9Kgh3X3rJQD",
>>"notification" : {
"body" : "great match!",
"title" : "Portugal vs. Denmark",
"icon" : "myicon"
}
}

获取通知,但

>> messaging.onMessage().then((payload) => {
console.log('Message received. ', payload);
alert("message",payload)
// [START_EXCLUDE]
// Update the UI to include the received message.
// appendMessage(payload);
// [END_EXCLUDE]});

不工作

您可以使用旧版本的FCM JS并手动设置它,因为它与您的angular不兼容。

相关内容

  • 没有找到相关文章

最新更新