-
PhoneGap-How to handle Push notification when application is resumed?
over 9 years ago
over 9 years ago
Hello friends,
As we have seen, cordova push plugin only provides access to notification action when we click on notification from status bar, but if we want to perform that action without clicking on notification we have to add some extra code.
- mBuilder = new NotificationCompat.Builder(context)
- .setDefaults(Notification.DEFAULT_ALL)
- .setSmallIcon(context.getApplicationInfo().icon)
- .setWhen(System.currentTimeMillis())
- .setContentTitle("Notification")
- .setContentText(jsonObject.getString("alert"))
- .setTicker(extras.getString("title"))
- .setContentIntent(contentIntent);
mBuilder = new NotificationCompat.Builder(context) .setDefaults(Notification.DEFAULT_ALL) .setSmallIcon(context.getApplicationInfo().icon) .setWhen(System.currentTimeMillis()) .setContentTitle("Notification") .setContentText(jsonObject.getString("alert")) .setTicker(extras.getString("title")) .setContentIntent(contentIntent);
- if ( e.foreground ){
- }else{
- //The user touched a notification in the notification tray.
- //when app in background and to the perticular page.
- }
- navigator.notification.alert(e.msg);
- break;
if ( e.foreground ){ }else{ //The user touched a notification in the notification tray. //when app in background and to the perticular page. } navigator.notification.alert(e.msg); break;
Here e.msg is the data or message which is returned by the GCM.
Can you help out the community by solving one of the following Mobile Development problems?
Do activity (Answer, Blog) > Earn Rep Points > Improve Rank > Get more opportunities to work and get paid!
For more topics, questions and answers, please visit the Tech Q&A page.
0 Comment(s)