phonegap / phonegap-plugin-push

Register and receive push notifications
MIT License
1.94k stars 1.91k forks source link

Heads Up Notification #603

Open dhavalmaru opened 8 years ago

dhavalmaru commented 8 years ago

Hi,

I require to show heads up notification like whatsapp does

Is it possible with this plugin?

Example of Heads - up: heads-up

macdonst commented 8 years ago

@dhavalmaru currently not supported. Pull Requests are welcome.

jimior2 commented 8 years ago

Request to have + 1.

leizard commented 8 years ago

+1 I'd love to have it also

moskeyombus commented 8 years ago

+1 would be cool to have this

wlkwok commented 8 years ago

+1 would like this as well!

akz92 commented 8 years ago

I'm using the branch v2.0.x and all I had to do was to add priority to my data payload like this:

{
    data: {
        priority: 1
    }
}
robgaleano commented 7 years ago

@akz92 excuse me but where do you put that setting if it's on typescript?? nothing about that is shown in the docs. That's for showing head's up on android right?

akz92 commented 7 years ago

@robgaleano you should put it on the data portion of your notification payload that's sent from (I presume) a web server i.e.:

{
    data: {
        title: 'Example',
        message: 'Example message',
        priority: 1
    }
}

EDIT: Yes, it's for Android.

robgaleano commented 7 years ago

@akz92 you mean on back-end side? i thought it was a configuration on front-end

akz92 commented 7 years ago

@robgaleano exactly. priority is set per notification.

robgaleano commented 7 years ago

@akz92 ok perfect i will try that, thanks a lot! only with that change it will show the notification like a heads-up right?

akz92 commented 7 years ago

@robgaleano right, but only if the app is in background. To show heads-up while the app is in foreground you need to set forceShow: true in the plugin initialization.

@macdonst this is actually already working on the master branch and if needed I could help documenting it.

robgaleano commented 7 years ago

@akz92 in which version is working? i already have the forceShow attribute set to true i'm using 1.8.4 version if there's a new version could you tell me how to update it?

akz92 commented 7 years ago

@robgaleano it works on the newest version (1.8.4). I didn't test on previous versions.

robgaleano commented 7 years ago

thanks for your help @akz92 i've managed to make it work but for some reason it only shows a heads-up when im inside the app. When the app is in background or foreground it just shows the icon and sounds/vibrate i don't understand why. Any thoughts or suggestions?

jimiatworking commented 7 years ago

@macdonst Set priority: 1 works for me. this issue could close though

Juanpam commented 6 years ago

I'm using this plugin and adding the priority field with a value of 1 (also tried with 2) and the notification appears but not the head up. It's the same problem whether the app is open or closed. Also tried adding forceShow: true and still the same. Do I need to do anything else to get it working? Thanks!

royston-c commented 6 years ago

@Juanpam did you resolve this? I'm getting the same result (v2.2.3).

Juanpam commented 6 years ago

Hello @roy46. Honestly, I've already forgotten if I did indeed resolve the issue but I think it was due to the specific smartphone I was trying the app on. It had some options regarding the app's notifications configuration. Specifically, the floating notifications were off for my app. I think turning it on fixed the issue for me. Good Luck!

royston-c commented 6 years ago

Thanks for the reply. I actually found the solution. The API has a createChannel function for Android where u can set the importance of the notifications on that channel. This value then dictates the head up pop up displaying or not.

https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/API.md#pushnotificationcreatechannelsuccesshandler-failurehandler-channel

Shoukd have read the docs better. Hope that helps anyone else in that same position.

machty commented 5 years ago

I was only able to get Heads-up notifications to work on Android Oreo by creating a channel with importance: 5. I'm also maintaining a separate default channel for less urgent messages.