android - GCM message sending successfully on server but not received on Device -
maybe second set of eyes can me here. can't seem in receiver, though i'm getting successful sends when posting gcm send url server.
manifest:
<uses-permission android:name="com.google.android.c2dm.permission.receive" /> <permission android:name="<pkgname>.permission.c2d_message" android:protectionlevel="signature" /> <uses-permission android:name="<pkgname>.permission.c2d_message" /> <receiver android:name="<pkgname>.gcmbroadcastreceiver" android:exported="true" android:permission="com.google.android.gcm.c2dm.permission.send" > <intent-filter> <action android:name="com.google.android.c2dm.intent.receive" /> <category android:name="<pkgname>" /> </intent-filter> </receiver> <service android:name="<pkgname>.gcmintentservice" />
= com.myappsname i've removed privacy sake
here server request , response:
{"registration_ids":[removed],"data":{"project":{"comment":"chubb","username":"dave thomas","time":"2014-12-05 15:33:13","projectid":5}}} {"multicast_id":removed,"success":2,"failure":0,"canonical_ids":1,"results":[{"message_id":"removed"},{"registration_id":"removed","message_id":"removed"}]}
so server sending successfully... not seeing on app side @ all. put break point @ start of receiver's onreceive method, , isn't catching anything.
receiver:
package <pkgname>; import android.app.activity; import android.content.componentname; import android.content.context; import android.content.intent; import android.support.v4.content.wakefulbroadcastreceiver; public class gcmbroadcastreceiver extends wakefulbroadcastreceiver { @override public void onreceive(context context, intent intent) { // explicitly specify gcmintentservice handle intent. componentname comp = new componentname(context.getpackagename(), gcmintentservice.class.getname()); // start service, keeping device awake while launching. startwakefulservice(context, (intent.setcomponent(comp))); setresultcode(activity.result_ok); } }
update found in log, know device geting message:
12-08 12:48:42.910: w/broadcastqueue(960): permission denial: broadcasting intent { act=com.google.android.c2dm.intent.receive flg=0x10 pkg=<pkgname> (has extras) } com.google.android.gsf (pid=28999, uid=10007) requires com.google.android.gcm.c2dm.permission.send due receiver <pkgname>/.gcmbroadcastreceiver
i think i've found issue
i see missing 2 permissions
<uses-permission android:name="<pkgname>.permission.c2d_message" /> <uses-permission android:name="android.permission.receive_boot_completed" />
and receiver declaration android:authorities="<pkgname>"
<receiver android:name="<pkgname>.gcmbroadcastreceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.send" android:authorities="<pkgname>"> <intent-filter> <action android:name="com.google.android.c2dm.intent.receive" /> <category android:name="<pkgname>" /> </intent-filter> </receiver>
Comments
Post a Comment