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

Not getting notifications alert on device #165

Closed
sun34133 opened this issue Oct 2, 2019 · 22 comments
Closed

Not getting notifications alert on device #165

sun34133 opened this issue Oct 2, 2019 · 22 comments
Labels
android Relates to Android platform Can't repro Unable to reproduce the issue as described runtime issue An issue related to app runtime support Support is being requested but not a necessarily a bug

Comments

@sun34133
Copy link

sun34133 commented Oct 2, 2019

Hello,

I am getting issue with the android notification. We are not getting an alert or indication of a notification anywhere on the mobile's interface.
Currently I am checking on an android device only. Will check it for ios device after this.

Cordova version: 9.0.0 (cordova-lib@9.0.1)
cordova-ios@5.0.1
cordova-android@8.1.0

Other plugins used as following:
br.com.brunogrossi.MediaScannerPlugin 0.1.3 "Media Scanner Plugin"
com.dawsonloudon.videoplayer 1.0.0 "VideoPlayer"
cordova-custom-config 5.1.0 "cordova-custom-config"
cordova-open-native-settings 1.5.2 "Native settings"
cordova-plugin-android-permissions 1.0.0 "Permissions"
cordova-plugin-androidx 1.0.2 "cordova-plugin-androidx"
cordova-plugin-androidx-adapter 1.1.0 "cordova-plugin-androidx-adapter"
cordova-plugin-certificates 0.6.4 "Certificate Plugin"
cordova-plugin-device 2.0.3-dev "Device"
cordova-plugin-dialogs 2.0.2 "Notification"
cordova-plugin-file 6.0.2-dev "File"
cordova-plugin-file-opener2 2.2.0 "File Opener2"
cordova-plugin-file-transfer 1.7.1 "File Transfer"
cordova-plugin-firebasex 6.1.0 "Google Firebase Plugin"
cordova-plugin-geolocation 4.0.2-dev "Geolocation"
cordova-plugin-google-analytics 0.8.1 "Google Universal Analytics Plugin"
cordova-plugin-inappbrowser 1.2.1 "InAppBrowser"
cordova-plugin-network-information 2.0.2 "Network Information"
cordova-plugin-splashscreen 5.0.3 "Splashscreen"
cordova-plugin-statusbar 2.4.3 "StatusBar"
cordova-plugin-whitelist 1.3.4 "Whitelist"

I have used cordova-plugin-androidx and cordova-plugin-androidx-adapter along with the cordova-plugin-firebasex.

@sun34133 sun34133 changed the title Not receiving notifications on devices Not getting notifications alert on device Oct 2, 2019
@sun34133
Copy link
Author

sun34133 commented Oct 2, 2019

I have tried using the https://github.com/dpa99c/cordova-plugin-firebasex-test by changing the package ID and google-services.json file. I sent notification using the firebase console and as per the test app logs, it show 'Notification message received'.
But I noticed one thing, in json response there is a key 'show_notification' and it has value 'false'.

@dpa99c
Copy link
Owner

dpa99c commented Oct 2, 2019

Are you testing with the app in the foreground (displayed), background or not running?

@dpa99c dpa99c added android Relates to Android platform runtime issue An issue related to app runtime support Support is being requested but not a necessarily a bug labels Oct 2, 2019
@sun34133
Copy link
Author

sun34133 commented Oct 2, 2019

This was an issue for both foreground as well as background. To be more clear about this issue
I am using firebase api endpoint for sending notifications. The issue seemed to have been because i was not adding notification index to the fields i.e i was sending title and body in the data index. It has been working fine for a couple of years now. This issue seems to have come up recently. I have been using this plugin before you forked it to support andriod x. Is there something that has changed in the plugin that would cause this behavior? Also even though i get the notification alert now, i am unable to use the data i send in the data index of the notification payload.

@dpa99c
Copy link
Owner

dpa99c commented Oct 2, 2019

This plugin has changed significantly from cordova-plugin-firebase to cordova-plugin-firebasex.
For example, the former did not support display of notifications while in the foreground whereas this fork does however this only works if you send the correct key in the data section as outlined in the documentation.

Note that if you send notification messages from the Firebase console, this key will not be present.
I recommend taking a look at the pre-defined messages in the example project which are send via the FCM v1 API.

The current plugin version has been regression tested using the example project on both iOS and Android and notifications are received and displayed when the app is in the foreground/background/not running.

I will regression test the delivery of the data payload from a system notification arriving when the app is background/not running when I get a moment to confirm this has not been broken in a recent version.

@sun34133
Copy link
Author

sun34133 commented Oct 3, 2019

I have added a few changes to the notification messages as per the pre-defined . I am getting the alert for the notifications now for both android and ios. But the data sent in the notification payload is still not working.

@dpa99c
Copy link
Owner

dpa99c commented Oct 3, 2019

But the data sent in the notification payload is still not working.

iOS or Android or both?
Running in foreground/running in background/not running/ or all of the above?

@dpa99c dpa99c added the awaiting response If no response, issue will be closed label Oct 3, 2019
@sun34133
Copy link
Author

sun34133 commented Oct 3, 2019

Sorry for the delay in response. Yes in both ios as well as android. I am running in foreground and not running, running in background (all places).

@dpa99c
Copy link
Owner

dpa99c commented Oct 3, 2019

I will regression test the data payload in all situations when I have some time

@dpa99c dpa99c added investigate Issue requires investigation and removed awaiting response If no response, issue will be closed labels Oct 3, 2019
@albertopq
Copy link

albertopq commented Oct 28, 2019

I have a similar issue, but only with notifications coming from an external service (Intercom).
If I send notifications through the https://github.com/dpa99c/cordova-plugin-firebasex-test script it works fine.

At the other hand, when I try to send a message from Intercom to that device, I can't see the notification in the device but adb logcat shows:

FirebasePlugin: sendMessage(): messageType=data; showNotification=false; id=47; title=null; body=null; sound=null; vibrate=null; light=null; color=null; icon=null; channel=null; data={app_id=******, image_url=****, receiver=intercom_sdk, avatar_color=#00E0B6, conversation_id=******, intercom_push_type=notification, body=***, author_name=****, message=****, app_name=*****, conversation_part_type=comment}"

One more hint is that if I use the message type 'android_data_notification_custom_channel' from the firebasex-test script, the situation is the same that I have with Intercom.

Could it be possible that messages with channel=null are being dismissed by the firebasex plugin? I tested with a clean cordova app just with the Intercom plugin, and it works. If I install firebasex (and change the intercom option to fcm-without-build) it stops working. Any idea on how can I workaround this?

Thanks!

@andysousa
Copy link

what is the payload you are sending in?

@albertopq
Copy link

The thing is that I don't control the payload of the notification. Intercom does :(

@andysousa
Copy link

hmm, you might have some trouble then... this requires some custom tags to do exactly what you want it to do. I will let @dpa99c tell you for sure, but i think you might have some troubles

@albertopq
Copy link

I'm talking to Intercom's engineering team, and I'll ask them about the payload. They are probably going to defend that if I uninstall cordova-plugin-firebasex, the notification is shown. Do you have any insight about why is that happening? Thanks!

@albertopq
Copy link

Some light to the issue:

The problem is that Intercom is sending a Data message with title and body instead of notification_title and notification_body, so the plugin detects that they are null and don't show the notification.

Is the FirebasePlugin payload specification something standard? I'm just trying to understand if Intercom should be sending the messages in your format, or if every app manage them in his way.

I'm wondering if is there any way to propagate the data message to the rest of plugins in order to be handled by them, or only one plugin can handle data messages. Any help?

Thanks.

@dpa99c
Copy link
Owner

dpa99c commented Oct 29, 2019

@albertopq

Is the FirebasePlugin payload specification something standard? I'm just trying to understand if Intercom should be sending the messages in your format, or if every app manage them in his way.

there is no specification for the data payload of an FCM data message - the payload is entirely arbitrary. By default Firebase does not display notifications for data messages, hence this plugin implements a mechanism to allow that to happen and it's bespoke to this plugin. However, it assumes that you have control over the FCM message structure being sent to the app, which in this case you don't.

I'm wondering if is there any way to propagate the data message to the rest of plugins in order to be handled by them, or only one plugin can handle data messages. Any help?

This plugin implements a mechanism (currently for Android only) by which another plugin can declare itself a "handler" for a specific message and so have this plugin ignore that message.
You can see an example plugin which implements this in the test project

@dpa99c
Copy link
Owner

dpa99c commented Oct 29, 2019

@sun34133 BTW I haven't forgotten your reason for opening this issue in the first place - I still have regression testing payload delivery in all scenarios/platforms on my TODO list. Hopefully I can get around to that soon.

@albertopq
Copy link

@albertopq

Is the FirebasePlugin payload specification something standard? I'm just trying to understand if Intercom should be sending the messages in your format, or if every app manage them in his way.

there is no specification for the data payload of an FCM data message - the payload is entirely arbitrary. By default Firebase does not display notifications for data messages, hence this plugin implements a mechanism to allow that to happen and it's bespoke to this plugin. However, it assumes that you have control over the FCM message structure being sent to the app, which in this case you don't.

I'm wondering if is there any way to propagate the data message to the rest of plugins in order to be handled by them, or only one plugin can handle data messages. Any help?

This plugin implements a mechanism (currently for Android only) by which another plugin can declare itself a "handler" for a specific message and so have this plugin ignore that message.
You can see an example plugin which implements this in the test project

That makes sense. I'll try implement the handler in the other plugin and see how it goes. Thanks!

@albertopq
Copy link

@dpa99c When sending a data message with notification (using the android_data_notification template) and the app is not running, I can see in adb logcat:

FirebasePlugin: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.app.Activity.getSystemService(java.lang.String)' on a null object reference

It works fine when the app is running in background. It seems that the method works with the context, but there is no context when is not running.

Any idea?

albertopq added a commit to albertopq/cordova-plugin-firebasex that referenced this issue Oct 31, 2019
@albertopq
Copy link

One more issue, now on iOS.
When I send a data-message through the firebasex-test script, it shows correctly the notification when the app is in background,but it shows nothing when the app is not running (closed).

Does this happen also to you guys? Thanks.

@dpa99c
Copy link
Owner

dpa99c commented Nov 9, 2019

@albertopq you need to include the content-available key in the APNS payload - please see the updated iOS background notifications doc section on the dev branch.
This is illustrated in the ios_notification_default_sound_and_badge.json message example also on the dev branch.
Note: I am preparing a release so dev will shortly be merged to master and released.

@dpa99c
Copy link
Owner

dpa99c commented Nov 9, 2019

@sun34133 I have regression test delivery of the data payload using the example project in all situations (foreground/background/not running) on iOS (using iPhone 7/iOS 13.2) and Android (using Android 10 on Pixel 2 XL) and found the data payload to be delivered in all cases.

If you are able to reproduce different results using the example project, please provide full details of the scenario, OS version, test device, native console log, etc.
Until such time, I'm closing this issue as unreproducible.

@dpa99c dpa99c closed this as completed Nov 9, 2019
@dpa99c dpa99c added Can't repro Unable to reproduce the issue as described and removed investigate Issue requires investigation labels Nov 9, 2019
dpa99c added a commit that referenced this issue Nov 9, 2019
…xt when app is not running and therefore cordovaActivity doesn't exist. Resolves #165.
@sun34133
Copy link
Author

sun34133 commented Nov 11, 2019

Hi @dpa99c Sorry for the delay response. I was away due to some personal issues. I will check with the example projects again with different scenarios and devices etc and will update you.

I am getting below issue with the latest version 7.0.0

Executing script found in plugin cordova-plugin-firebasex for hook "after_prepare": plugins/cordova-plugin-firebasex/scripts/after_prepare.js
(config.widget.plugin || []).forEach is not a function
TypeError: (config.widget.plugin || []).forEach is not a function
at parsePluginVariables (../plugins/cordova-plugin-firebasex/scripts/after_prepare.js:48:34)
at module.exports (../plugins/cordova-plugin-firebasex/scripts/after_prepare.js:73:3)
at runScriptViaModuleLoader (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:181:32)
at runScript (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:157:16)
at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:125:20
at processTicksAndRejections (internal/process/next_tick.js:81:5)

I will check with older version 6.1.0 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Relates to Android platform Can't repro Unable to reproduce the issue as described runtime issue An issue related to app runtime support Support is being requested but not a necessarily a bug
Projects
None yet
Development

No branches or pull requests

4 participants