onMessageReceived wasn't called with secondary process
See original GitHub issue[REQUIRED] Step 2: Describe your environment
- Android Studio version: 2020.3.1 patch 2
- Firebase Component: com.google.firebase:firebase-messaging
- Component version: 23.0.3
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
I found many ANR that related with “Reason: Broadcast of Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x1000010 pkg=com.redtech.hivisualer cmp=com.redtech.hivisualer/com.google.firebase.iid.FirebaseInstanceIdReceiver (has extras) }” . someone said if set FCM Service to seondary process in the manifest , this ANR will be reduced ,So I try this method ,but onMessageReceived was never called when I push msg to my android device, notification icon was not shown on my phone too.
Relevant Code:
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// TODO(developer): Handle FCM messages here.
// Not getting messages here? See why this may be: https://goo.gl/39bRNJ
Log.d(TAG, "From: " + remoteMessage.getFrom());
// Check if message contains a data payload.
if (remoteMessage.getData().size() > 0) {
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
}
// Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
}
}
<service
android:name=".HiVisualerFCMService"
android:exported="false"
android:process=":light"
tools:node="replace">
<intent-filter android:priority="-500">
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND"
android:process=":light"
tools:node="replace">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</receiver>
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Android notifications: onMessageReceived not called
onMessageReceived most likely is being called, but terminated. ... If still no response then you can use the Tomin's second method.
Read more >Firebase Messaging (FCM) OnMessageReceived Running ...
I am using Firebase Messaging to send/Receive Push Notification on Android. I've got the following implementation which is triggering ...
Read more >Receive messages in a Flutter app - Firebase - Google
The firebase_messaging package provides a simple API for requesting permission via the requestPermission method. This API accepts a number of named arguments ...
Read more >Firebase Cloud Messaging Push Notifications Android tutorial
And second service class MyFirebaseMessagingService will extend ... onMessageReceived method is not called and we have not processed ...
Read more >Android Notifications with Firebase Cloud Messaging - Medium
If you do not have one, go to accounts.google.com/signup to sign up for one. ... The method is called every time it receives...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
As mentioned, this is not officially supported, but I will note that your app-specific FirebaseMessagingService (HiVisualerFCMService) should probably be using the default priority (nothing specifically set in the manifest) instead of being set at -500 priority.
Hello @wangjianpeng, thanks for the minimal repro. From what I’ve tested, I’m still experiencing the same issue (I’m not able to receive any notifications) with your app.
I understand that you’re trying to lessen the ANRs in your app, however this type of experimental configuration is not officially documented, hence is not supported.
As to quote from the blog:
Unfortunately, there’s not much I can do since I don’t think the current versions of FCM supports this type of setup. That being said, I’ll be closing this now.