Closed saricden closed 4 years ago
Hey guys, I solved it on my own! It was an error in my impementation.
I was sending an FCM w/ a data
key, but I needed to send one with a notification
key.
:shipit: :shipit: :shipit:
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.
Bug Report
Capacitor Version
npx cap doctor
output:Affected Platform(s)
Current Behavior
I'm using
PushNotifiations.register()
andPushNotifications.addListener('...')
to register my app and listen for notifications. I'm sending notifications to the correct token from a Firebase function on my server. Now, whether the app is in the background or the foreground, thePushNotification.addListener('pushNotificationReceived')
callback is triggered and no notification shows. Note that when I try to send a notification to the device token via the Firebase messaging test form it works as expected.Expected Behavior
I would expect the
'pushNotificationReceived'
callback to only fire when the app is in the foreground. I also expect a notification to show when the app is closed or in the background.Sample Code or Sample Application Repo
Frontend code (React):
Serverside code (Firebase function):
Reproduction Steps
Send a FCM to an Android app created w/ Capacitor & React, using the
PushNotifications
plugin. It's a bit of a complicated setup, but as far as I can tell the'pushNotificationReceived'
is being triggered when it shouldn't be, and a notification should be shown instead.Other Technical Details
npm --version
output:(Yarn)
node --version
output:pod --version
output (iOS issues only):n/a (Android only at this point).
Other Information