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