android - easiest way to make GCM registration working on real devices less than 4 -
my application gcm(using google play service) registration works fine on real device samsung running on android 4, does't working on galaxy gt-5360 running on android 2.3.6
after half-day of searching how make gcm registration working on real devices, don't helpful results.
but search not go down drain, these solutions found not resolve problem.
1.first solution:
link: gcm service_not_available on android 2.2
i experienced same problem. gcm works fine on tablet running android 4.04, received service_not_available on smartphone running android 2.3.
i found following workaround not using (so far know) deprecated classes. add action "com.google.android.c2dm.intent.registration" gcmbroadcastreceiver in manifest. enable receive registration_id @ 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 gcmbroadcastreceiver able receive 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("")) { /* ever want regid eg. send server */ } }
although still service_not_available error, can handle registration_id in gcmbroadcastreceiver , able send messages smartphone. quite weird, works me.
i try solution added registration action in receiver , onreceive method on gcmbroadcastreceiver. run nothing want work !!! no logcat messages...
2.second solution:
checking internet connection, check google accounts on device...
please save day , give me experience make gcm registration working on android 2.x.x
thanks in advance :)
finally have found easiest way make android push notifications working on android 2.2 , later.
the ways following steps in link below:
https://developer.android.com/google/gcm/helper.html
although it's deprecated, found adequate, it's working , want.
Comments
Post a Comment