I'm receiving that error from Android Studio's Android Monitor. This error appears when I send a push notification through GCM, in a real device, and the app has not been started yet or has been forced to stop. Yesterday all works fine, today is not working at all (works only if the app is running in background or foreground).
I think this may be an AndroidManifest
error, but I'm tired of looking for the problem and can not find anything.
Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.flagg327.guicomaipu"> ... <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> ... <!--GOOGLE CLOUD MESSAGE--> <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="android.intent.action.BOOT_COMPLETED"/> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- for Gingerbread GSF backward compat --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="com.flagg327.guicomaipu" /> </intent-filter> </receiver> <service android:name="com.flagg327.guicomaipu.gcm.RegistrationService" android:exported="false" /> <service android:name="com.flagg327.guicomaipu.gcm.TokenRefreshListenerService" android:exported="false"> <intent-filter> <action android:name="com.google.android.gms.iid.InstanceID" /> </intent-filter> </service> <service android:name="com.flagg327.guicomaipu.gcm.NotificacionsListenerService" android:exported="false" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> </intent-filter> </service> </aplication> <permission android:name="com.flagg327.guicomaipu.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="com.flagg327.guicomaipu.permission.C2D_MESSAGE" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
TokenRefreshListenerService.java
The registration 'tokens' updates every day. It because that, each Android app that uses GCM must have an InstanceIDListenerService that manages those updates.
public class TokenRefreshListenerService extends InstanceIDListenerService{ @Override public void onTokenRefresh() { // Launch the registration process. Intent i = new Intent(this, RegistrationService.class); startService(i); } }
NotificacionsListenerService.java
GCM automatically shows up the push notifications, but only if the associated app has a GCMListenerService
public class NotificacionsListenerService extends GcmListenerService { @Override public void onMessageReceived(String from, Bundle data) { Log.d("A", "onMessageReceived()"); // Do something } }
RegistrationService.java
GCM identifies the Android devices using registration cards('tokens').My app should be able to register from each Android device on which it is installed.
public class RegistrationService extends IntentService { /** * Constructor */ public RegistrationService() { super("RegistrationService"); } @Override protected void onHandleIntent(Intent intent) { // Generate or download the registration 'token'. InstanceID myID = InstanceID.getInstance(this); String registrationToken = null; try { // Get the registration 'token'. registrationToken = myID.getToken( getString(R.string.gcm_defaultSenderId), GoogleCloudMessaging.INSTANCE_ID_SCOPE, null ); // Subscribe to a topic. The app is able now to receive notifications from this topic. GcmPubSub subscription = GcmPubSub.getInstance(this); subscription.subscribe(registrationToken, "/topics/guico_maipu_topic", null); } catch (IOException e) { e.printStackTrace(); } Log.e("Registration Token", registrationToken); } }
Error
This error appears when I send a push notification via python.
09-13 21:21:44.800 1851-1851/? W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.flagg327.guicomaipu (has extras) }
Yesterday was working... Any idea? Than you for your time.
Since none of answers provide official link, I decided to ask firebase team and got official answer from them
It looks like you have an issue when your app is force stopped or killed. Actually, this is working as intended. The Android framework advises that apps that have been stopped (i.e. killed/force-stopped from Settings) should not be started without explicit user interaction. FCM follows this recommendation and thus its services will not start as well. This also means that messages will not be received (FirebaseMessagingService will not be called) when the app is in "killed" state. Here are some useful links so you could have a better understanding on this topic: https://developer.android.com/about/versions/android-3.1#launchcontrols https://github.com/firebase/quickstart-android/issues/368#issuecomment-343567506
In sum:
NOTE: even the question is about GCM, but FCM throw exact the same error in the question title.
I got the same Error
09-13 21:21:44.800 1851-1851/? W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.XXX.XXX (has extras) }
after killing the app.
After some research I realized, that this is only a "Debug-Issue". A "signed APK" handles the broadcast correctly even if the app has been shut down.
Hope it helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With