googleCloudMessaging.register()方法失败的原因是什么

时间:2014-12-09 04:25:00

标签: android push-notification google-api

我现在面临实施推送通知的麻烦。我在sharedPreferences中保存return registerId。在googleCloudMessaging.register()方法失败时,我必须检查sharedPrefernces为null或为空。但我不知道失败登记的回报是什么。 有人能帮我吗? 谢谢。

1 个答案:

答案 0 :(得分:1)

我相信你应该把你的调用包装在try-catch语句中的register()方法中。根据文档,如果在注册时出现问题,它应该抛出IOException,您可以根据需要处理它。查看开发人员网站上提供的此示例,它可能会对您有所帮助。 https://developer.android.com/google/gcm/client.html