How to send one to one message using Firebase Messaging

后端 未结 5 1377
Happy的楠姐
Happy的楠姐 2020-11-22 04:30

I have been trying to read the official docs and guides about how to send message from one device to another. I have saved registration token of both devices in the Real Tim

5条回答
  •  长情又很酷
    2020-11-22 05:20

    According to the new documentation which was updated on October 2, 2018 you must send post request as below

    https://fcm.googleapis.com/fcm/send
    Content-Type:application/json
    Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA //Server key
    
    {
        "to": "sent device's registration token",
        "data": {
           "hello": "message from someone",
        }
    }
    

    To get device's registration token extend FirebaseMessagingService and override onNewToken(String token) For more info refer to doc https://firebase.google.com/docs/cloud-messaging/android/device-group

提交回复
热议问题