user-interface-samples icon indicating copy to clipboard operation
user-interface-samples copied to clipboard

E/FirebaseMessaging: Notification pending intent canceled in android P

Open giricodebase opened this issue 5 years ago • 6 comments

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 ?

giricodebase avatar Jul 05 '19 12:07 giricodebase

Same here!

hansemannn avatar Jul 10 '19 21:07 hansemannn

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

TheEnsis avatar Jul 12 '19 04:07 TheEnsis

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

ClarkNguyen avatar Sep 09 '19 19:09 ClarkNguyen

Any update on this? I am facing the same problem.

akumar-atheer avatar Jul 31 '20 04:07 akumar-atheer

@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

robertofrontado avatar Aug 31 '20 19:08 robertofrontado

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>

rami-alloush avatar Oct 01 '20 19:10 rami-alloush