Google Cloud Messaging - GCM - SERVICE_NOT_AVAILABLE

我与影子孤独终老i 提交于 2019-12-02 22:11:07

The problem was not code related, but link to the test phone. The test phone do not have a SIM, and the clock was not set. So google cannot resgistred it with a wrong time.

I manage to have a registration Id using a Android Virtual Device, with google api, and by setting the test phone clock.

Ryan Gray
android:enabled="true"  

Remove this ^

If you don't already add this to your manifest

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8"

You don't need the second constructor in GCMIntentService. only this one

public GCMIntentService() {         
 super(SENDER_ID);  }

Ensure that your SENDER_ID is the number copied out of the URL from your browser while you are browsing the google code website AND browsing the GCM service.

Remember that if you're behind a corporate firewall, some ports that GCM uses may not be allowed to communicate over the local wireless. I had this problem when trying to get my emulator to work initially. I had to get a special IP that allowed the ports listed below through.


Note: If your organization has a firewall that restricts the traffic to or from the Internet, you need to configure it to allow connectivity with GCM in order for your Android devices to receive messages. The ports to open are: 5228, 5229, and 5230. GCM typically only uses 5228, but it sometimes uses 5229 and 5230. GCM doesn't provide specific IPs, so you should allow your firewall to accept outgoing connections to all IP addresses contained in the IP blocks listed in Google's ASN of 15169.

http://developer.android.com/google/gcm/gcm.html

I had this problem...my solution was to disable internet connection and use the phone service.

Vinícius Barbosa

I've had this problem and it was caused by the WIFI connection. I turned WIFI off and made the test again (on 3g) and it Worked. Then I turned the WIFI back on and had the error again. Back to 3g, to make sure, and it worked again.

So, in conclusion, the issue was caused by the connection.

kelvincer

I had this problem running my application on genymotion. Installing google play services like it says here and everything worked fine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!