GCM返回notRegisteded

时间:2016-04-09 14:08:06

标签: android google-cloud-messaging

这是我的Java代码。

@Override
protected void onHandleIntent(Intent intent) {
    // Make a call to Instance API
    InstanceID instanceID = InstanceID.getInstance(this);
    String senderId = getResources().getString(R.string.gcm_defaultSenderId);
    try {
        // request token that will be used by the server to send push notifications
        String token = instanceID.getToken(senderId, GoogleCloudMessaging.INSTANCE_ID_SCOPE,null);
        Log.d(TAG, "GCM Registration Token: " + token);

        // pass along this data
        sendRegistrationToServer(token);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

我复制了注册ID,并使用邮递员将通知推送到Android设备,它给出了错误:notRegistered。

这是我的邮递员请求

网址:https://gcm-http.googleapis.com/gcm/send

 {
  "to": "<registration_Key>",
  "data": {
    "message": "This is a GCM Topic Message!"
   }
 }

我尝试复制密钥,我尝试在nodejs中创建一个休息端点,它将接收此密钥并执行gcm请求,但在这两种情况下都会返回以下响应。

{
    "multicast_id": 7402052379497307216,
    "success": 0,
    "failure": 1,
    "canonical_ids": 0,
    "results": [
      {
         "error": "NotRegistered"
      }
    ]
 }

0 个答案:

没有答案