phonegap-build / PushPlugin

This repository is deprecated head to phonegap/phonegap-push-plugin
https://github.com/phonegap/phonegap-plugin-push
MIT License
1.32k stars 1k forks source link

Get notifications in the status bar when the app is running #696

Open mbachaalani opened 7 years ago

mbachaalani commented 7 years ago

Hello,

I am able only to receive a notification on the status bar when the app is in the background. In the old plugin there was a possibility to receive it in the background and foreground in the status bar by using the following:

if(!window.plugins) { window.plugins = {}; } if (!window.plugins.pushNotification) { window.plugins.pushNotification = new PushNotification(); } window.plugins.statusBarNotification.notify(data.tag,data.title,data.message);

But in the latest push plugin I cannot use the above because I have to pass a options parameter when I use new PushNotification() which I don't know what it should be. (I tried to pass android attribute with the project id as object but still it did not work).

Any help would be appreciated. Thank you.

alouane commented 7 years ago

I ended by doing a very dirty job, go to GCMintentService.java & add this line createNotification(context, extras); you will have something like this: extras.putBoolean("foreground", true); PushPlugin.sendExtras(extras); createNotification(context, extras);

But right now I'm trying to fix notifications display when the app is not running , do you have a fix to this issue?

coolvasanth commented 6 years ago

If you're using ionic then below plugin will help you. http://ionicframework.com/docs/native/local-notifications/