1

I'm using the Cordova phonegap-plugin-push plugin

  <plugin name="phonegap-plugin-push" spec="1.6.0">
    <variable name="SENDER_ID" value="MYID"/>
  </plugin>

I'm using this plugin with iOS and it's ok.

Android can show notifications only if the app is open or running in background, but never if the app is closed.

( It does not work on some devices like ASUS ZENFONE 2, but instead works on LG for example)

This is my mobile configuration :

var push = PushNotification.init({
     android: {
                senderID: "XXXXXXXX",
                sound: true,
                vibrate: true,
                forceShow: true,
                badge: true,
                clearBadge: true,
                clearNotifications: true
                },
                ios: {
                    alert: "true",
                    badge: "true",
                    sound: "true",
                    clearBadge: "true"
                }
});

This is the example message sent from NodeJS server:

   var gcm = require('node-gcm');
   var apiKey = "API-key";
   var deviceID = "device-id";
   var service = new gcm.Sender(apiKey); 
   var message = new gcm.Message();
   message.addData('title', 'Large Icon');  
   message.addData('message', 'Loaded from drawables folder.');
   message.addData('image', 'twitter');
   service.send(message, { registrationTokens: [ deviceID ] },function(){})

I also tried adding these parameters, but it does not work anyway

message.addData('priority', 2);
message.addData('visibility', 1);
message.addData('vibrate', 1);
message.addData('collapse_key', "demo");
message.addData('delay_while_idle', true);
message.addData("time_to_live" ,3);
message.addData('sound', 1);
message.addData('info', 'super secret info');
message.addData('content-available', '1');
message.addData('badge', 1);
message.addData('foreground', true);
message.addData('summaryText', 'test');
message.addData('vibrationPattern', [2000, 1000, 500, 500]);
message.addData('ledColor', [0, 0, 255, 0]);

The Problem is not that my app dont recieve the event, the Problem is that my Device wont show the Notification in the "notification area". How can I see notifications also the app closed?

Plugin : phonegap-plugin-push - version 1.6.0 (https://github.com/phonegap/phonegap-plugin-push) Cordova version : 6.2.0

jay
  • 1,453
  • 1
  • 11
  • 30
  • Possible duplicate of [Push notification works incorrect when app is on background or not running](http://stackoverflow.com/questions/37876257/push-notification-works-incorrect-when-app-is-on-background-or-not-running) – Tim Jul 12 '16 at 14:12
  • could you include the AndroidManifest.xml file to the question? – Arthur Thompson Jul 14 '16 at 18:02
  • Yes of course @ArthurThompson https://gist.github.com/andreaj8/43edf01775a3cb708f6e80e5de18c206 – jay Jul 15 '16 at 09:10
  • I tried it with other devices and It does not work on some devices like ASUS ZENFONE 2, but instead works on LG for example – jay Jul 15 '16 at 10:07

0 Answers0