phonegap / phonegap-plugin-push

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

Allow to conditionally force notifications when app is in foreground (Feature suggestion) #522

Open tzafrir opened 8 years ago

tzafrir commented 8 years ago

(Android platform, maybe relevant to other platforms too?)

Use case: In-app chat screen. I'd like to show notifications to the user when new messages come in, but not when the user is currently in the chat screen.

Similar behavior can be seen in Whatsapp, Google Hangouts, etc.

From what I gather, the "forcePush" setting is global and cannot be set per push, or consult with application state to decide if to show push or not.

macdonst commented 8 years ago

@tzafrir you could use the local notification plugin to do this or alternatively just provide your own UI.

candidodmv commented 8 years ago

@macdonst which local notification plugin you are referring?

macdonst commented 8 years ago

@candidodmv https://github.com/katzer/cordova-plugin-local-notifications

candidodmv commented 8 years ago

@macdonst But the mentioned plugin have the same behavior described above by @tzafrir . See bellow:

"The essential purpose of local notifications is to enable an application to inform its users that it has something for them — for example, a message or an upcoming appointment — when the application isn’t running in the foreground."

This text was copied from your suggest plugin repository https://github.com/katzer/cordova-plugin-local-notifications on the first paragraph.

fredgalvao commented 8 years ago

The essential purpose

Doesn't mean it won't work on other scenarios.

Notifications scheduled through that plugin will work regardless of your app's state at the time of the trigger event (check their doc on events to know what's the trigger event about). If you schedule it (remember, scheduling to {new Date()} is still scheduling) it when the app is on foreground, it'll still trigger.

geshub commented 8 years ago

Just checking again now that IOS10 seems to allow foreground notifications. Would it be possible to show push notifications even when the application is running in the foreground ?

gianpaj commented 7 years ago

This would be great. as cordova-plugin-local-notifications doesn't have foreground notifications that are expanded, ie. not only the icon at the top (as far I could find)

HectorFGarcia commented 7 years ago

Any news about this?

Pigsnuck commented 6 years ago

Just a note that phonegap-plugin-local-notifications / cordova-plugin-local-notifications doesn't play nice with phonegap-plugin-push.

I would also like to see a feature built into phonegap-plugin-push to display local notifications, as presently I can't find any reliable way to achieve this due to the incompatibility. I also tried another local notification plugin which also didn't work with phonegap-plugin-push. :(