如何知道哪个registration_id不良/过期/删除



所以我将批处理中的通知推到多个设备。如果它们不在firebase中,我想从数据库中删除设备GFCM令牌。

测试请求:

{"registration_ids": ["fznIum-OIL0:APA91bE9n6gxqVEB3hR0On_TZqH_cOOO7rFyLE5MYbvKXUX3737IonXquZRoHeY1UJf20G4nrahz35p80X8PAPouviYvXgtekAzeDFuwaWyiPI1sFlN1d1wGp5OulXv9wUzHyegeZiih","dsasadadsasdasdasdasdefs","fjb0qTB9ACI:APA91bHvx0pSlq-NuQz-bU70DhL7BXAcd-DqT9YT0ZjYw7R_pkBmr8oe6XdNw8IPlU67d-rXMfRY3mybaO7K5GHo_NH7G-Ya1Ae2xxJP1JIbuuSYomz31y_MPQijFK8w-bZXQ26SWE09"],
"notification":{
    "body":"Yoou have a new message from Alice"}}

和响应:

{
  "multicast_id": 7971310728176484096,
  "success": 1,
  "failure": 2,
  "canonical_ids": 0,
  "results": [
    {
      "error": "NotRegistered"
    },
    {
      "error": "InvalidRegistration"
    },
    {
      "message_id": "0:1481547993513035%4f9c20964f9c2096"
    }
  ]
}

如何检测哪些registration_ids不良/未注册?

谢谢!

okey,我想我已经弄清楚了。

"结果":返回响应/错误,您在registration_ids

中指定的顺序返回响应/错误
when you are sending push notification to any mobile,you can find in err that registartion_ids/token isbad /not registered/
        var serverKey = 'sdasd';//server key
        var fcm = new FCM(serverKey);
        var token = "token";//token here
        var message = {
            to: token,
            collapse_key: 'your_collapse_key',
            notification: {title: 'hello', body: 'test'},
            data: {my_key: 'my value', contents: "stackoverflow.com"}
        };
        fcm.send(message, function (err, response) {
            if (err) {
               console.log(err);//find here registration_ids are bad/Not registered? 
            } else {
                console.log(response);
            }
        });
    });

最新更新