google cloud messaging - can't receive message gcm android below lollipop -
i'm not able receive gcm messages on devices running android below lollipop. push messages works on android 5, 6 , 7. don't know why ... there app code:
manifest:
<uses-sdk android:minsdkversion="19" android:targetsdkversion="25"/> <uses-permission android:name="android.permission.wake_lock" /> <uses-permission android:name="android.permission.internet" /> <permission android:name="sbntt.android.xenoss.permission.c2d_message" android:protectionlevel="signature" /> <uses-permission android:name="sbntt.android.xenoss.permission.c2d_message" /> <application android:name="android.support.multidex.multidexapplication" android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsrtl="true" android:theme="@style/apptheme"> <receiver android:name="com.google.android.gms.gcm.gcmreceiver" android:exported="true" 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="sbntt.android.xenoss" /> </intent-filter> </receiver> <service android:name="sbntt.android.xenoss.gcmpushreceiverservice" android:exported="false" > <intent-filter> <action android:name="com.google.android.c2dm.intent.receive" /> </intent-filter> </service> <service android:name=".gcmregistrationintentservice" android:exported="false"> <intent-filter> <action android:name="com.google.android.gms.iid.instanceid" /> </intent-filter> </service> <service android:name=".gcmtokenrefreshlistenerservice" android:exported="false"> </service> </application>
gcmpushreceiverservice class
@override public void onmessagereceived(string from, bundle data) { string message = data.getstring("message"); if (settings.preference != null) { if (settings.preference.getboolean("notifications", true)) { sendnotification(message); } } else { sendnotification(message); } } private void sendnotification(string message) { intent intent = new intent(this, mainactivity.class); intent.addflags(intent.flag_activity_clear_top); int requestcode = 0; pendingintent pendingintent = pendingintent.getactivity(this, requestcode, intent, pendingintent.flag_one_shot); uri sound = ringtonemanager.getdefaulturi(ringtonemanager.type_notification); notificationcompat.builder nobuilder = new notificationcompat.builder(this) .setsmallicon(r.drawable.ic_menu_youtube) .setcontenttitle("title") .setcontenttext(message) .setautocancel(true) .setcontentintent(pendingintent) .setsound(sound) .setdefaults(notification.default_all) .setpriority(notification.priority_high); notificationmanager notificationmanager = (notificationmanager)getsystemservice(context.notification_service); notificationmanager.notify(0, nobuilder.build()); }
registration works fine! help.
gcm need updated play service on devices . can notify users update play service or use less play service version in project .
Comments
Post a Comment