Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E/FirebaseMessaging: Notification pending intent canceled in android P #98

Open
srigiri92 opened this issue Jul 5, 2019 · 6 comments
Open
Assignees
Labels
migrated googlesamples Issue migrated from old repo location (googlesamples/)

Comments

@srigiri92
Copy link

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 ?

@hansemannn
Copy link

Same here!

@TheEnsis
Copy link

TheEnsis commented Jul 12, 2019

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

@ClarkNguyen
Copy link

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

@codingjeremy codingjeremy transferred this issue from googlearchive/android-Notifications Sep 27, 2019
@codingjeremy codingjeremy added the migrated googlesamples Issue migrated from old repo location (googlesamples/) label Sep 27, 2019
@codingjeremy codingjeremy self-assigned this Sep 27, 2019
@akumar-atheer
Copy link

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

@robertofrontado
Copy link

robertofrontado commented Aug 31, 2020

@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

@rami-alloush
Copy link

rami-alloush commented Oct 1, 2020

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
migrated googlesamples Issue migrated from old repo location (googlesamples/)
Projects
None yet
Development

No branches or pull requests

8 participants