GCM SERVICE_NOT_AVAILABLE on Android 2.2

后端 未结 9 1522
青春惊慌失措
青春惊慌失措 2020-11-27 06:21

I am getting the error \"SERVICE_NOT_AVAILABLE\" on my GoogleCloudMessaging.register() call on a Android 2.2 device.

I am writing an app that uses GoogleCloudMessagi

相关标签:
9条回答
  • 2020-11-27 06:47

    After reading the post from marnanish, I tried the code below, and I have successfully got my Activity to receive a registration. Just add this:

    <activity
        android:name=".MyActivity"
        ... />
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="your.package.here" />
        </intent-filter>
    </activity>
    

    in your AndroidManifest.xml

    0 讨论(0)
  • 2020-11-27 06:48

    SERVICE_NOT_AVAILABLE may be caused by an old or missing GooglePlayServices. Use GooglePlayServicesUtil to check the version and if wrong redirect to market so user can manually install it - this will fix the SERVICE_NOT_AVAILABLE and also get all improvements and bug fixes ( and new bugs :-).

    If you can't do this - there is no point in using register(), the method expects the matching play service to retrieve the result. It does generate the same broadcast, for backward compatibility. Using the REGISTER intent directly or the deprecated library will continue to work - I would suggest using the intent, GCMRegistrar is tied to the old implementation in GoogleServicesFramework (it has a call to intent.setPackage(GSF_PACKAGE)), so it can't benefit from any fixes.

    Having the latest version of GCM - by using GooglePlayServicesUtil to deal with devices that didn't get the automatic install - can help not only for registration.

    0 讨论(0)
  • 2020-11-27 06:49

    I know this is an old post, but I just had the same problem, while everything was setup correctly. The SERVICE_NOT_AVAILABLE error, kept popping up. After going to settings => apps => Google Play-servises, and clear the cache and remove the data, it worked.

    0 讨论(0)
提交回复
热议问题