google cloud messaging - GCM messages are not received with android app at all -
i have old problem: cannot receive gcm messages android app. according server log succesfully delivered gcm server , sent further, client side app doesn't seem have received them.
this gcm-relevant fragment of manifest:
<uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> <!-- gcm requires google account. --> <uses-permission android:name="android.permission.get_accounts" /> <!-- keeps processor sleeping when message received. --> <uses-permission android:name="android.permission.wake_lock" /> <uses-permission android:name="android.permission.vibrate" /> <!-- app has permission register , receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.receive" /> <uses-permission android:name="android.permission.read_phone_state" /> <permission android:name="my.package.permission.c2d_message" android:protectionlevel="signature" /> <uses-permission android:name="my.package.permission.c2d_message" /> <receiver android:name="com.google.android.gms.gcm.gcmreceiver" android:permission="com.google.android.c2dm.permission.send" > <intent-filter> <!-- receives actual messages. --> <action android:name="com.google.android.c2dm.intent.receive" /> <action android:name="com.google.android.c2dm.intent.registration" /> <action android:name="com.google.android.c2dm.intent.gcm_received_action" /> <category android:name="my.package" /> </intent-filter> </receiver> <service android:name=".gcmintentservice" />
this service-class gcmintentservice:
public class gcmintentservice extends gcmlistenerservice { private string tag = "myreceiver"; @override public void onmessagereceived(string from, bundle data) { log.d(tag, "message received");//this log never shown if (!data.isempty()) { log.d(tag, "interesting message receiver"); } } }
this project build.gradle dependency:
classpath 'com.google.gms:google-services:1.3.0-beta1'
i think forgot add something, that's why doesn't work @ all. tried wlan , sim-card internet. promblem not in internet firewall. sender api , gcm-token seem correct (they copied , pasted corresponding settings of developer account).
thank in advance.
edit: see answer below
do following changes in manifest
replace following code
<service android:name=".gcmintentservice" />
with
<service android:name="packagename.mygcmlistenerservice" android:exported="false" > <intent-filter> <action android:name="com.google.android.c2dm.intent.receive" /> </intent-filter> </service>
and in
<uses-permission android:name="your.package.name.permission.c2d_message" />
write whatever youer packagename in place of "your.package.name"
Comments
Post a Comment