Last active
March 28, 2017 02:53
-
-
Save jcesarmobile/f2afd8fe68f4ad14ffb4 to your computer and use it in GitHub Desktop.
notify.js del tutorial para enviar notificaciones push desde node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gcm = require('node-gcm'); | |
var sender = new gcm.Sender('AIzaSyCdkyeCkVWgsV1RiWOzfWQ_1WW2m8pWfow');//API key de la parte 1 del tutorial | |
var registrationIds = []; | |
var message = new gcm.Message(); | |
message.addData('message',"\u270C Peace, Love \u2764 and PhoneGap \u2706!"); | |
message.addData('title','Push Notification Sample' ); | |
message.addData('msgcnt','3'); // Se muestra en la notificación en la barra de tareas. | |
message.addData('soundname','beep.wav'); //Sonido en el dispositivo para avisar de la llegada | |
message.timeToLive = 3000;// Duración en segundos que permanecerá en GCM e intentarlo de nuevo antes de finalizar. Por defecto son 4 semanas (2,419,200 segundos) si no se especifica. | |
registrationIds.push('APA91bHuJxSIdubORY8G-GN_ZlD5AcWkxv7p5Mw3f_A5lTp1BsZrUUL47v6Iu3cEq5teX-SkEHNjFv-1_c9GytnLLUnMZ4MsDuSiRnN0jAhJYYnoLSPgIMLWkgCOam6zWOu_GiN9hebumKeSadH1WUUtwKtcCLjUpQ'); // Id del dispositivo obtenida en la parte 2 del tutorial | |
sender.send(message, registrationIds, 4, function (err,response) { | |
if(err) { | |
console.error(err); | |
} else { | |
console.log(response); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment