GCM错误codeS [英] GCM Error Codes

查看:484
本文介绍了GCM错误codeS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个服务器应用程序,发送GCM推送通知。每次发送的1000收件人返回一条消息,告诉我每个注册ID的状态。有些人会拥有C $ CS错误$。是否有一个文档的地方从谷歌,告诉我如何,我希望来处理这些codeS,什么都可能出现的错误codeS是什么?我的谷歌富不转任何东西。

I've got a server app that sends GCM push notifications. Each send of 1000 recipients returns a message that tells me the status of each registration ID. Some will have error codes. Is there a document somewhere from Google that tells me how I'm expected to handle these codes and what all the possible error codes are? My Google foo isn't turning up anything.

推荐答案

您没看够硬。所有codeS在这里解释下 国米preting错误响应

You didn't look hard enough. All the codes are explained here under Interpreting an error response.

我试图复制和粘贴,以便它不是一个链接仅回答,但格式是有点过了:

I tried to copy and paste it in order for it not to be a link only answer, but the formatting is a bit off:

国米preting错误响应

下面是处理不同类型的错误的建议   尝试发送一个消息给一个设备时,可能会发生:

Here are the recommendations for handling the different types of error that might occur when trying to send a message to a device:

丢失的注册ID       检查该请求中包含的注册ID(无论是在在纯文本消息的registration_id参数,或在   registration_ids场JSON)。       发生在错误code是 MissingRegistration

Missing Registration ID Check that the request contains a registration ID (either in the registration_id parameter in a plain text message, or in the registration_ids field in JSON). Happens when error code is MissingRegistration.

无效的注册ID       请检查您传递到服务器的注册ID的格式。请确保它的注册ID手机接收匹配   在com.google.android.c2dm.intent.REGISTRATION意图和你是   不截断它或添加其他字符。       发生在错误code是 InvalidRegistration

Invalid Registration ID Check the formatting of the registration ID that you pass to the server. Make sure it matches the registration ID the phone receives in the com.google.android.c2dm.intent.REGISTRATION intent and that you're not truncating it or adding additional characters. Happens when error code is InvalidRegistration.

不匹配的发件人       注册ID被绑定到某一组的发件人。当一个应用程序注册为GCM使用时,必须指定发件人是   允许发送信息。请确保你使用的时候之一   试图将消息发送到该设备。如果您切换到不同   发件人,现有注册的ID将无法正常工作。当发生错误   code是 MismatchSenderId

Mismatched Sender A registration ID is tied to a certain group of senders. When an application registers for GCM usage, it must specify which senders are allowed to send messages. Make sure you're using one of those when trying to send messages to the device. If you switch to a different sender, the existing registration IDs won't work. Happens when error code is MismatchSenderId.

未注册装置       现有注册ID可能不再有效了一些方案,包括:

Unregistered Device An existing registration ID may cease to be valid in a number of scenarios, including:

      
  • 如果应用程序手动注销通过发出一个com.google.android.c2dm.intent.UNREGISTER意图。
  •   
  • 如果该应用程序会自动注册的,它可以发生(但并不保证)如果用户卸载应用程序。
  •   
  • 如果注册ID到期。谷歌可能会决定刷新注册的ID。
  •   
  • 如果该应用程序已经更新,但新的版本没有配置为接收com.google.android.c2dm.intent.RECEIVE意图广播接收器。
  •   
  • If the application manually unregisters by issuing a com.google.android.c2dm.intent.UNREGISTER intent.
  • If the application is automatically unregistered, which can happen (but is not guaranteed) if the user uninstalls the application.
  • If the registration ID expires. Google might decide to refresh registration IDs.
  • If the application is updated but the new version does not have a broadcast receiver configured to receive com.google.android.c2dm.intent.RECEIVE intents.

有关所有这些情况下,您应该删除从第三方服务器这个注册ID和停止使用它来发送邮件。       发生在错误code是 NotRegistered

For all these cases, you should remove this registration ID from the 3rd-party server and stop using it to send messages. Happens when error code is NotRegistered.

消息太大       有效载荷数据的总大小被包括在消息中不能超过4096个字节。注意,这包括以下两者的大小   键以及值。       发生在错误code是 MessageTooBig

Message Too Big The total size of the payload data that is included in a message can't exceed 4096 bytes. Note that this includes both the size of the keys as well as the values. Happens when error code is MessageTooBig.

无效数据的关键       有效载荷数据包含一个键(如来自或通过谷歌pfixed任何价值$ P $)在内部使用GCM的   com.google.android.c2dm.intent.RECEIVE意图,并且不能使用。注意   某些词语(如collapse_key)也利用GCM但   在有效负载允许的,在这种情况下,有效载荷值将是   由GCM值覆盖。       发生在错误code是 InvalidDataKey

Invalid Data Key The payload data contains a key (such as from or any value prefixed by google.) that is used internally by GCM in the com.google.android.c2dm.intent.RECEIVE Intent and cannot be used. Note that some words (such as collapse_key) are also used by GCM but are allowed in the payload, in which case the payload value will be overridden by the GCM value. Happens when the error code is InvalidDataKey.

无效的生存时间       为生存时间字段的值必须重新$ P $的整数psenting在秒的持续时间介于0和2419200(4周)。   发生在错误code是 InvalidTtl

Invalid Time To Live The value for the Time to Live field must be an integer representing a duration in seconds between 0 and 2,419,200 (4 weeks). Happens when error code is InvalidTtl.

验证错误       那你想用它来发送邮件的发件人帐户无法进行身份验证。可能的原因有:

Authentication Error The sender account that you're trying to use to send a message couldn't be authenticated. Possible causes are:

      
  • 在Authorization头缺失或无效的语法。
  •   
  • 将作为重点无效的项目编号。
  •   
  • 键有效,但会禁用GCM的服务。
  •   
  • 请求源自于服务器密钥的IP白名单中没有一台服务器。
  •   
  • Authorization header missing or with invalid syntax.
  • Invalid project number sent as key.
  • Key valid but with GCM service disabled.
  • Request originated from a server not whitelisted in the Server Key IPs.

请检查您要发送的授权头中的令牌是与项目相关的正确的API密钥。您可以   通过运行以下命令来检查你的API密钥的有效性:

Check that the token you're sending inside the Authorization header is the correct API key associated with your project. You can check the validity of your API key by running the following command:

API_KEY = YOUR_API_KEY

api_key=YOUR_API_KEY

卷曲--header授权:键= $ API_KEY--header内容类型:应用/ JSON的 HTTPS:/ /android.googleapis.com/gcm/send -d{\registration_ids \:\ABC \]}

curl --header "Authorization: key=$api_key" --header Content-Type:"application/json" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"ABC\"]}"

如果您收到一个401 HTTP状态code,你的API密钥无效。否则,你应该看到这样的事情:

If you receive a 401 HTTP status code, your API key is not valid. Otherwise you should see something like this:

{"multicast_id":6782339717028231855,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}

{"multicast_id":6782339717028231855,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}

如果您想确认一个注册ID的有效性,你可以通过注册ID替换ABC这样做的。   发生在HTTP状态code为401。

If you want to confirm the validity of a registration ID, you can do so by replacing "ABC" with the registration ID. Happens when the HTTP status code is 401.

超时       服务器无法处理及时请求。你应该重新尝试同样的请求,但是必须遵守以下规定:

Timeout The server couldn't process the request in time. You should retry the same request, but you MUST obey the following requirements:

华艺Retry-After头,如果它包括在从GCM服务器的响应。   实现指数回退中的重试机制。这意味着每个失败的重试后的指数增加的延迟(例如   如果第一个重试前等待一秒,等待至少两   第二下一个之前,然后4秒等)。如果你是   发送多条消息,由一个独立延迟每一个   附加随机量,以避免发出针对所有新的请求   消息在同一时间。           发件人导致问题的风险被列入黑名单。           发生在HTTP状态code是501和599,或者在结果数组的JSON对象的错误域之间   不可用。

Honor the Retry-After header if it's included in the response from the GCM server. Implement exponential back-off in your retry mechanism. This means an exponentially increasing delay after each failed retry (e.g. if you waited one second before the first retry, wait at least two second before the next one, then 4 seconds and so on). If you're sending multiple messages, delay each one independently by an additional random amount to avoid issuing a new request for all messages at the same time. Senders that cause problems risk being blacklisted. Happens when the HTTP status code is between 501 and 599, or when the error field of a JSON object in the results array is Unavailable.

内部服务器错误       在尝试处理请求的服务器遇到错误。你可以重试相同的请求(服从要求   在超时部分中列出),但如果错误仍然存​​在,请   在android-GCM组中报告问题。       发生在HTTP状态code是500,或者在结果数组的JSON对象的错误字段是 InternalServerError

Internal Server Error The server encountered an error while trying to process the request. You could retry the same request (obeying the requirements listed in the Timeout section), but if the error persists, please report the problem in the android-gcm group. Happens when the HTTP status code is 500, or when the error field of a JSON object in the results array is InternalServerError.

无效的包装名称的消息是写给一个注册ID的包名不匹配请求传递的值。发生在错误code是 InvalidPackageName

Invalid Package Name A message was addressed to a registration ID whose package name did not match the value passed in the request. Happens when error code is InvalidPackageName.

修改(2015年6月6日):

一个新的错误响应codeS表已经公布这里

A new error response codes table has been posted here.

新的错误响应:

设备信息率超过了消息发送到特定设备的比率过高。减少发送到该装置的消息的数量,并且不立即重试传送至该设备

Device Message Rate Exceeded The rate of messages to a particular device is too high. Reduce the number of messages sent to this device and do not immediately retry sending to this device.

话题留言率超过了消息的速度给用户一个特定的主题过高。减少发送此主题邮件的数量,并不会立即重新尝试发送。

Topics Message Rate Exceeded The rate of messages to subscribers to a particular topic is too high. Reduce the number of messages sent for this topic, and do not immediately retry sending.

这篇关于GCM错误codeS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆