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

onBackgroundMessage not fired and app not opening on notification click #104

Closed
pilz97 opened this issue Jul 16, 2019 · 12 comments
Closed

Comments

@pilz97
Copy link

pilz97 commented Jul 16, 2019

Hi,

I have two problems.
The onBackgroundMessage Event is not triggered, i only receive the onMessage when the App is in foreground while i receive a message.
At first I also didn't get the onMessage but then i added this to my config.xml:
<config-file target="AndroidManifest.xml" parent="/manifest/application" > <service android:name="by.chemerisuk.cordova.firebase.FirebaseMessagingPluginService"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT"/> </intent-filter> </service> </config-file>

Is there anything I have to add that i get the onBackgroundMessage to?

The second problem I have is, when i recevie a notification in the background, the push notification appears but when i click on it the app won't come in the foreground :(

Does anyone have a idea what I'm doing wrong?

@saurabh47
Copy link

Hello @pilz97 ,
I'm also facing same issue.
Do you got the solution for it??

@deepa1-d
Copy link

deepa1-d commented Mar 2, 2020

Facing the same issue in Android as well as iOS.

@jcarloss
Copy link

Same issue :(

@AxiomAim
Copy link

AxiomAim commented Apr 24, 2020

@chemerisuk Excellent plugin, thank you for all the work. I am facing the same issue on Android. Works on iOS. Also, the payload sent by my server does not include notification so I am not receiving a notification at all when the app is terminated.
{ "to" : "YOUR_FCM_TOKEN_WILL_BE_HERE", "collapse_key" : "type_a", "data" : { "body" : "Sending Notification Body From Data", "title": "Notification Title from Data", "key_1" : "Value for key_1", "key_2" : "Value for key_2" } }
I am also an android developer. Please let me know if I can be of any help to solve this.

@theMSY
Copy link

theMSY commented Jun 30, 2020

Hello,
I found out that removing the click_action attribute from the notification config array ( i wrote my backend in PHP), resolves the issue. Apparently, the firebase plugin takes charge of creating the appropriate intent and launches the app on its own. No need to add a click_action filter name, because it confuses firebase (?) and leads to canceling the intent all together.

@jackdaniel9
Copy link

Same issue. «cordova.plugins.firebase.messaging.onBackgroundMessage» not Work on Android.

@luisVargasGu
Copy link

Hello,
I found out that removing the click_action attribute from the notification config array ( i wrote my backend in PHP), resolves the issue. Apparently, the firebase plugin takes charge of creating the appropriate intent and launches the app on its own. No need to add a click_action filter name, because it confuses firebase (?) and leads to canceling the intent all together.

Getting rid of click_action does solve the issue if you don't have a custom data payload, or if the data payload is just title and body.

When I send just title and body, or custom data elements which are empty in a notification payload and the app is in the background. If i click the notification, it opens up the app hitting the .onBackgroundMessage function.

example payload:
{
"notification": {
"title": "test title",
"body": "test body"
},
"data": {
"title": "test title",
"body": "test body",
"link": ""
}
}

However when I send some custom data In my case a url link such as www.example.com, If I click the notification it does not open up the app, and it does not hit the .onBackgroundMessage function.

example payload:
{
"notification": {
"title": "test title",
"body": "test body"
},
"data": {
"title": "test title",
"body": "test body",
"link": "www.example.com"
}
}

If the app is in the foreground any and all payloads hit the .onMessage

@nimishdesai1989
Copy link

I am facing the same issue. Does anyone have any solution for a workaround ?

@helloworld123456780
Copy link

Hi, just curious if this issue is already fixed, especially with function onBackgroundMessage not fired?

@chemerisuk
Copy link
Owner

@fcristini
Copy link

Hi, I can't find the notes section of onBackgroundMessage anymore, is removing the click_action the solution for this?

@dllort
Copy link

dllort commented Mar 16, 2023

The problem is that in FirebaseMessagingPlugin.sendNotification() there is a check "if (instance != null)" that simply ignores push notifications if the app is not initialized, INSTEAD OF INITIALIZE IT. @chemerisuk can this plugin perform this initialization in order to enable push notification when the app is closed?

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