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

Problem with on('notification') callback in app's background #2828

Open
damirsel opened this issue Sep 26, 2019 · 20 comments

Comments

@damirsel
Copy link

@damirsel damirsel commented Sep 26, 2019

Expected Behaviour

Application should trigger on('notification') callback when push notification is clicked, however this is not happening.

Actual Behaviour

Once push notification is clicked application is switched to foreground without triggering the on('notification') callback. I've tried setting 'content-available': 1 flag, but still no results.

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

Android 8.1

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

Generic (emulator)

Cordova CLI version and cordova platform version

cordova --version 9.0.0 (cordova-lib@9.0.1)
cordova platform version android  android 8.0.0

Plugin version

cordova plugin version | grep phonegap-plugin-push 2.2.3

Sample Push Data Payload

{"sound":"default","title":"New post from Web App","message":"20190926162925","additionalData":{"dismissed":false,"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"\u0000*\u0000data":{"msg":"20190926162925","img_url":"https://xxx-public.s3.us-west-2.amazonaws.com/uploads/upload_363_Xj4NVriLidmnvzWu_instagram.png","service":"instagram","account_username":"some_dude","content-available":"1"}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}},"coldstart":false,"foreground":false}}

Sample Code that illustrates the problem

Logs taken while reproducing problem

@50l3r

This comment has been minimized.

Copy link

@50l3r 50l3r commented Sep 27, 2019

I have the same problem

@ildarnm

This comment has been minimized.

Copy link

@ildarnm ildarnm commented Sep 29, 2019

I faced with same problem. For me helped this part of the documentation:
https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#notification-vs-data-payloads
Try to put title and body to data property

{
  "data": {
    "title": "Test Notification",
    "body": "This offer expires at 11:30 or whatever",
    "notId": 10,
    "surveyID": "ewtawgreg-gragrag-rgarhthgbad"
  }
}

But now when receiving a notification, the sound does not play 😪

@damirsel

This comment has been minimized.

Copy link
Author

@damirsel damirsel commented Sep 30, 2019

@ildarnm thanks for the suggestion, but it seems like this doesn't work for me, not even with no sound scenario you mentioned...

@dejanmarkovic

This comment has been minimized.

Copy link

@dejanmarkovic dejanmarkovic commented Sep 30, 2019

I am having the same problem too.
please help

@sjregan

This comment has been minimized.

Copy link

@sjregan sjregan commented Oct 4, 2019

But now when receiving a notification, the sound does not play 😪

I am having this issue too, I want the sound to play and I want the event handler to be called when the notification is clicked while the app is in the background.

@ildarnm Did you find a way around this?

@ildarnm

This comment has been minimized.

Copy link

@ildarnm ildarnm commented Oct 4, 2019

@sjregan not yet. I can only assume this is related with this commit cc45534

today I will check it.

@wildhart

This comment has been minimized.

Copy link

@wildhart wildhart commented Oct 9, 2019

Same problem here. No callback when notification is received and app is in background.

@dejanmarkovic

This comment has been minimized.

Copy link

@dejanmarkovic dejanmarkovic commented Oct 9, 2019

@sjregan @ildarnm @50l3r
Were you guys able to solve the issue?
I am more than willing to hire somebody to help us out.

Thanks

@wennerma

This comment has been minimized.

Copy link

@wennerma wennerma commented Oct 15, 2019

Was anyone able to resolve this issue? I've been having the same issue on iOS(in emulator and on device). I receive the notification, but the on('notification') callback is not happening.

@ildarnm

This comment has been minimized.

Copy link

@ildarnm ildarnm commented Oct 17, 2019

@dejanmarkovic

This comment has been minimized.

Copy link

@dejanmarkovic dejanmarkovic commented Oct 17, 2019

Hi @ildarnm, thank you so much for notifying us about that library!
Can you please let us know if you have tested the notifications and confirm that they are working with that library?

Thank you so much.

@dmitryuk

This comment has been minimized.

Copy link

@dmitryuk dmitryuk commented Oct 25, 2019

We have created addon to this plugin
https://github.com/RoboFinance/CordovaPushDelivery

@jomorr

This comment has been minimized.

Copy link

@jomorr jomorr commented Oct 28, 2019

We have created addon to this plugin
https://github.com/RoboFinance/CordovaPushDelivery

Can you explain how to use this plugin? I looked at your GitHub page, but there isn't much info there.

@dmitryuk

This comment has been minimized.

Copy link

@dmitryuk dmitryuk commented Oct 29, 2019

@jomorr I have updated README, so if you will have any questions, you can contact me privately.

@jomorr

This comment has been minimized.

Copy link

@jomorr jomorr commented Oct 29, 2019

@dmitryuk - Thanks! I see the note that this is only for Android. The majority of my users are on iOS, so I need to find a solution for both.

@dmitryuk

This comment has been minimized.

Copy link

@dmitryuk dmitryuk commented Oct 29, 2019

If you will help with iOS in the addon it will be great!

@damirsel

This comment has been minimized.

Copy link
Author

@damirsel damirsel commented Nov 5, 2019

hi @dmitryuk thanks for the contribution on solving this issue, but there are some things I would like to know regarding your plugin, so far README is not that clear to me.

  1. we still need to have phonegap-plugin-push installed along with your plugin correct?
  2. how do we actually handle POST request sent from your plugin to http://localhost/set-read/886d27ee-f6fd-11e9-832d-362b9e155667 and extract the data - some simple example of that would be enough.
  3. I would encourage you to provide some examples on your README page since they would be very useful to many people.
@dmitryuk

This comment has been minimized.

Copy link

@dmitryuk dmitryuk commented Nov 6, 2019

@damirsel I have updated readme, if something will not be cleared for you, please open the issue there and 100% I will help you.

@jomorr

This comment has been minimized.

Copy link

@jomorr jomorr commented Nov 14, 2019

If you will help with iOS in the addon it will be great!

Unfortunately I am not a developer, so I am not able to help.

@pipoa

This comment has been minimized.

Copy link

@pipoa pipoa commented Nov 20, 2019

this bug last for a very long time, at least , over a year. Is there any solution on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
10 participants
You can’t perform that action at this time.