APNS with NODEJS
Posted By : Himanshu Goyal | 14-Mar-2016
Intro: For sending push notification we have to use
APNS (Apple Push Notification Server) is third
Code:
1. Install
npm install apn
2.
var apn = require('apn');
3.Make the object of connection
var options = ;
var apnConnection = options;
4.Create the device Object and put the hexadecimal device token in
var myDevice = new apn.Device(token);
5.Create the notification object to set the other setting like
var notificationObject = new apn.Notification();
notificationObject.alert=message //which you want to send on mobile screen
notificationObject.payload={} //any other data which you want to sent to mobile side for provide other information
6.Set the notification object and send to
apnConnection.pushNotification(notificationObject, myDeviceObject);
Set the various option in
a)pfx:here we set the path of p12 file
b)cert:here we set the path of cert.pem
c)key: here we set the path of key.pem
d)passphrase:here we set the password of certificates
e)gateway:here we put the url of gateway because there are two enviorement one is for production and second for development
f)production: true/false if we use production environment then set to be true otherwise it is false for development
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Himanshu Goyal
Himanshu is a bright Java ,Mean stack developer and have good knowledge of Hibernate, Spring,FFmepg,Neo4j JSON, Jquery, NODE.JS .His hobbies are learning new things, fitness .