FCM格式问题

FCM formatting issue

我将使用以下内容发送到 Firebase 云消息传递:

https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=[SERVER_KEY] (The one found in Firebase Project>Settings>Cloud Messaging

Body:
{
    "notification" = {
        "title": "Title",
        "text": "Your Text",
        "sound": "default",
        "badge": "1"
     },
    "to" = "a4fbc860-23fd-4ffc-95b7-11c90d8db320" (The Device ID from the hand held)
}

当我发送这个时,我不断收到:{"results":[{"error":"InvalidRegistration"}]}

我确定我缺少的是一些简单的东西。文档不是很清楚需要哪些元素,并且错误消息和 Firebase 站点之间的命名法不同。我尝试用 "to" 换出 "registration_ids"(当然是使用数组),但结果是一样的。

发送到单个设备时,"to" 字段应指定 FCM 注册令牌,而不是设备 ID。您可以使用 FirebaseInstanceId.getInstance().getInstanceId() 方法检索注册令牌。

这个标记看起来像两个字符串,一短一长,用冒号分隔,例如"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1..."

相关文档的链接: