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

Android 13+ app doesn't trigger on('notification') when clicking notification while app is closed or running in background #288

Open
redbird19 opened this issue Sep 6, 2024 · 6 comments

Comments

@redbird19
Copy link

FYI, I'm using cordova-plugin-push 4.0.0 and testing with my Android 13 phone.

When the app is closed, or running in background, and a notification is received, clicking the notification will open the app, but not fire the on('notification') event, which prevents the app from automatically redirecting the user to the appropriate location in the app related to the notification. This only seems to affect Android 13+.

FYI, if I have the app open when the notification is received, the app correctly fires the on('notification') event, enabling automatic redirection to the appropriate location.

In iOS, things work perfectly, clicking the notification with the app closed, or running in background, opens the app AND fires the on('notification') event allowing the user to be automatically redirected to the appropriate location in the app.

@Guillermo-G-M
Copy link

Same issue here

@ciuffo81
Copy link

Hi,
we had the same issue, we found the solution here
#266 (comment)

You can try to put in your payload this
"click_action": "com.adobe.phonegap.push.background.MESSAGING_EVENT"

@redbird19
Copy link
Author

redbird19 commented Sep 12, 2024

Thanks @ciuffo81, however, I haven't been able to get it to work even after adding the "click_action". I tried different ways of setting the click_action, first trying to add it to the "notification" property/object, but received an invalid JSON payload error.

Here's my code showing all the places I've tried to include the "click_action" property, including the commented out places that caused invalid JSON payload errors:

var response = await _sender.SendAsync(
    new {
        message = new
        {
            token = devicePushToken,
            notification = new {
                title = subjectOrTitle,
                body = bodyContent,
                //click_action = "com.adobe.phonegap.push.background.MESSAGING_EVENT" // This throws invalid JSON payload received error
            },
            android = new {
                notification = new {
                    click_action = "com.adobe.phonegap.push.background.MESSAGING_EVENT" // This has no effect
                }
            },
            data = new
            {
                notificationType = notificationType,
                notificationArgs = notificationKey),
                click_action = "com.adobe.phonegap.push.background.MESSAGING_EVENT" // This has no effect
            },
            //click_action = "com.adobe.phonegap.push.background.MESSAGING_EVENT" // This throws invalid JSON payload received error
        },
        //click_action = "com.adobe.phonegap.push.background.MESSAGING_EVENT" // This throws invalid JSON payload received error
    }
);

In looking at this https://firebase.google.com/docs/cloud-messaging/concept-options#notifications, it appears that utilizing the "android.notification.click_action" property is the proper way of doing it, but it has a not effect from my tests.

I also looked at the issue you linked to and saw someone had a problem with a missing entry in the manifest, but I've verified my manifest file has the following:

<activity android:exported="true" android:name="com.adobe.phonegap.push.BackgroundHandlerActivity" android:permission="${applicationId}.permission.BackgroundHandlerActivity">
    <intent-filter>
        <action android:name="com.adobe.phonegap.push.background.MESSAGING_EVENT" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

Nothing seems to work.

@vlads63
Copy link

vlads63 commented Sep 18, 2024

Have you been able to find a solution? I am having the exact same issue and none of the suggested solutions work for me.

@redbird19
Copy link
Author

No, I haven't found a solution yet.

@ElliotNB
Copy link

ElliotNB commented Sep 18, 2024

I'm experiencing the same issue as well. I've made a few different attempts at a fix (including the example above), but I haven't been able to get it to work.

@erisu Would you be able to weigh in on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants