2

My application GCM(Using google play service) registration works fine on my real device Samsung running on Android 4, but it does't working on Galaxy GT-5360 running on Android 2.3.6

After a half-day of searching about how to make GCM registration working on real devices, I don't get any helpful results.

But my search not go down the drain, these solutions that I found but they are not resolve my problem.

1.First solution:

Link: GCM SERVICE_NOT_AVAILABLE on Android 2.2

I experienced the same problem. GCM works fine on my Tablet running Android 4.04, but always received a SERVICE_NOT_AVAILABLE on my smartphone running Android 2.3.

I found following workaround not using (so far as I know) any deprecated classes. Add the action "com.google.android.c2dm.intent.REGISTRATION" to the GCMBroadcastReceiver in your manifest. This will enable to receive the registration_id at your GCMBroadcastReceiver.

<receiver
   android:name="YOUR_PACKAGE_NAME.GCMBroadcastReceiver"
   android:permission="com.google.android.c2dm.permission.SEND" >
      <intent-filter>
         <action android:name="com.google.android.c2dm.intent.RECEIVE" />
         <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

         <category android:name="YOUR_PACKAGE_NAME" />
      </intent-filter>
</receiver>

After that your GCMBroadcastReceiver is able to receive the registration_id:

public void onReceive(Context context, Intent intent) {
   Log.e("GCMTEST", "onReceive method invoked ??????");
   String regId = intent.getExtras().getString("registration_id");
   if(regId != null && !regId.equals("")) {
      /* Do what ever you want with the regId eg. send it to your server */
   }
}

Although I still get a SERVICE_NOT_AVAILABLE error, I can handle the registration_id in my GCMBroadcastReceiver and I am able to send messages to my smartphone. Quite weird, but it works for me.

I try with this solution where I added REGISTRATION action in the receiver and onReceive method on GCMBroadcastReceiver. I run it but nothing want to work !!! no logCat messages...

2.Second solution:

Checking internet connection, check Google accounts on the device...

Please save my day and give me your experience about make GCM registration working on Android 2.x.x

Thanks in advance :)

Community
  • 1
  • 1
parse
  • 1,706
  • 17
  • 27

1 Answers1

0

Finally I have found the easiest way to make Android Push Notifications working on Android 2.2 and later.

The ways is following the steps in the link below:

https://developer.android.com/google/gcm/helper.html

Although it's deprecated, I found it adequate, it's working and that what I want.

parse
  • 1,706
  • 17
  • 27