firebase-android-sdk
firebase-android-sdk copied to clipboard
onMessageReceived() is not called in newest Android
[READ] Step 1: Are you in the right place?
Issues filed here should be about bugs in the code in this repository. If you have a general question, need help debugging, or fall into some other category use one of these other channels:
- For general technical questions, post a question on StackOverflow with the firebase tag.
- For general Firebase discussion, use the firebase-talk google group.
- For help troubleshooting your application that does not fall under one of the above categories, reach out to the personalized Firebase support channel.
[REQUIRED] Step 2: Describe your environment
- Android Studio version: Hedgehog | 2023.1.1 Patch 2, Jellyfish | 2023.3.1 Patch 1
- Firebase Component: Messaging
- Component version: Via firebase-bom:33.1.0
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
What happened? How can we make the problem occur? MyFirebaseMessagingService class is declared in Manifest, app receive Token from onNewToken() function. However, onMessageReceived is never called.
Relevant Code:
// TODO(you): code here to reproduce the problem
@Override
public void onMessageReceived(@NonNull RemoteMessage message) {
super.onMessageReceived(message);
LogUtil.e( "From: " + message.getFrom());
if (message.getData().size() > 0) {
for (String key : message.getData().keySet()) {
LogUtil.e("Key: " + key);
LogUtil.e("Value: " + message.getData().get(key));
}
}
if (message.getNotification() != null) {
LogUtil.e( "Message Notification Title: " + message.getNotification().getTitle() +
" Body:" + message.getNotification().getBody());
}
sendNotification("Received Push");
}
And this is manifest
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<application
android:name="com.sollyfaks.tehillim.MyApp"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar"
android:usesCleartextTraffic="true"
tools:replace="android:allowBackup"
>
<service
android:name=".fcm.MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
I gave Notifications permission manually
Also tried to send test notification like document.
https://firebase.google.com/docs/cloud-messaging/android/first-message#send_a_test_notification_message
Important thing is old phones (Galaxy S8, android version 9) works, but my new phone (S21, android version 14) didn't work.
App is targeting Android 33