I'm in process of development of Cordova hybrid app. I was unable to find any information on how to turn on the LED of the phone when new notification from GCM is received. I currently have sound and vibration of the phone but not LED notification when the screen of the phone is off. Any help is appreciated.
Asked
Active
Viewed 354 times
1 Answers
0
Try to check this thread if it can help you. According to this, You can use a Led notification and choose the color of it. Just add a ledColor
field in your notification in the ARGB format array:
{
"registration_ids": ["my device id"],
"data": {
"title": "Green LED",
"message": "This is my message with a Green LED",
"ledColor": [0, 0, 255, 0]
}
}
And here is an example using node-gcm that sends the above JSON:
var gcm = require('node-gcm');
// Replace these with your own values.
var apiKey = "replace with API key";
var deviceID = "my device id";
var service = new gcm.Sender(apiKey);
var message = new gcm.Message();
message.addData('title', 'Green LED');
message.addData('message', 'This is my message with a Green LED');
message.addData('ledColor', [0, 0, 255, 0]);
service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) {
if(err) console.error(err);
else console.log(response);
});
For more information, check this SO question.
-
Thanks a lot for the lead. Do you know if it's possible to handle LED light when sending GCM from server side script (PHP)? I did check the documentation and unfortunately they don't have setting for LED when sending notification. – George Nikolov Jan 29 '17 at 10:12