I can receive FCM Remote push notification when I boot my phone and actually open the app. I receive the notifications if the app is in the foreground or background as expected. However, I expect to also receive the push notifications if the user has not yet opened the app. I do not receive these notifications, in other words, when the app is killed or has not yet been opened.
In my logcat I see the following error:
GCM-DMM : broadcast intent callback: result=CANCELLED forIntent
{ act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=com.lisdo (has extras) }
After googling I came across this question.
It suggests, that in the AndroidManifest.xml something is missing to register these FCM events, but I thought the steps in the READ.ME would cover this scenario.
Any ideas??
I am running on an actual android device for testing (Xiaomi Mi Mix) and I do receive remote PN from other apps (WhatsApp, etc.).
"react-native": "^0.47.1",
"react-native-fcm": "^13.3.3",
xiaomi has app notification permission in its setting, make sure you turn that on.
it whitelist some popular apps as whatsapp and facebook automatically
@evollu I have all permission granted for my app and it still isnt working. Any other idea?
can you reproduce it with example app?
Yes, Ill try to do it.
Are you using C2DM in react-native-fcm?
Here is my AndroidManifest if you notice anything weird:
Thank you for your help! :)
```
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:largeHeap="true"
android:launchMode="singleInstance"
android:theme="@style/AppTheme">
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"
/>
<meta-data
android:name="com.google.android.geo.apikey"
android:value="apikey"
/>
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/ic_notif"/>
<service android:name="com.evollu.react.fcm.MessagingService" android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name="com.evollu.react.fcm.InstanceIdService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<receiver android:name="com.evollu.react.fcm.FIRLocalMessagingPublisher"/>
<receiver android:enabled="true" android:exported="true" android:name="com.evollu.react.fcm.FIRSystemBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
seems right to me.
also try to reproduce in android emulator
@evollu I just tried it on a google pixel in the emulator and it works fine.
Seems to be an issue with phones running MIUI.
Thank you for your time!!
I have the same error on my Nexus 5X. I'll try to debug this somehow..
@wmonecke it's a problem with autostart I think, this permission is different from the app permissions. I created a library exactly for this Autostarter.
You can take a look at its description which gives you a quick summary of what exactly your're facing.
This issue only occurs on non stock android phones.
I have this problem on Meizu m1 note
@judemanutd is This help you? Any solution for Meizu?
try this
<permission android:name="${applicationId}.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
@pahnpiseth what this? Where is answer?
@KORuL i'm edited.
@pahnpiseth Wow Thank you so much. you help me a lot. i stuck for a week for that problem with oppo android o.
Most helpful comment
try this