user-interface-samples
user-interface-samples copied to clipboard
E/FirebaseMessaging: Notification pending intent canceled in android P
Im getting error "E/FirebaseMessaging: Notification pending intent canceled" while clicking on the notification,
this happens when the app is in background and push came try to open it getting the error, App also not opening. But all works fine in below P version even background works.
Any changes Do I need to-do in-order to support P version ?
Same here!
me too even android O
edit : found the reason that my app was not opening when click notification in background mode is i added "click_action" in notification model when i send it. after remove it my app work normal.
ref : https://stackoverflow.com/questions/56924836/firebase-api-push-doesnt-open-background-app-on-android-device
me too even android O
edit : found the reason that my app was not opening when click notification in background mode is i added "click_action" in notification model when i send it. after remove it my app work normal.
ref : https://stackoverflow.com/questions/56924836/firebase-api-push-doesnt-open-background-app-on-android-device
but if you remove that "click_action", you can't use both "notification" and "data" attributes at same time
Any update on this? I am facing the same problem.
@akumar-atheer are you sending click_action
? I faced the same issue today, problem was I was missing an intent-filter
in the manifest for that particular action
<activity ...>
<intent-filter>
<action android:name=CLICK_ACTION />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Note: CLICK_ACTION will be whatever action you are sending
Build on what everyone else said, there doesn't seem to be a bug here. When we remove the click_action
from the notification payload, the system automatically opens the default activity that has the <intent-filter>
e.g. MainActivity
and sends the data part as intent extras. More on this here
When we do have the click_action
we must have an <intent-filter>
with the name
set to that action, otherwise we get the mentioned error. A working example is the following.
From Firebase SDK
const notificationPayload = {
notification: {
title: 'Your title here',
body: 'Your body here' ,
},
webpush: {
notification: {
icon: 'https://domain.com/logo.png',
},
fcmOptions: {
link: `https://domain.com`,
}
},
android: {
"notification": {
"click_action": "OPEN_PROFILE"
}
},
}
Inside AndroidManifest.xml
<activity
android:name=".activity.ProfileActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="OPEN_PROFILE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>