Full post on:
http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1
Checklist:
1. Create CSR
http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1
Checklist:
1. Create CSR
2. Create iOS Development + iOS Distribution certificates
3. Create provisioning (dev/prod) and register them to your xcodes
4. Create new AppID
5. Enable both development and production APN Service
6. Create two different certificates using two CSR files
%SCREEN_SHOT%
%SCREEN_SHOT%
7. For each certificate
- Download aps_production/aps_development certificate
- Double click on it and save it to your keychain
- Export p12 key
- Run openSsl to create two pem files (public and private key)
%SCREEN_SHOT%
openssl x509 -in aps_development.cer -inform der -out cert.pem
openssl pkcs12 -nocerts -out key.pem -in MyExportedKey.p12
For the second statement you'll need to create a "passphrase" that will be useful later on.
NodeJs part using node-apn
NodeJs part using node-apn
var fs = require( 'fs' );
var apn = require('apn');
var options = {cert: 'cert.pem',key: 'key.pem',passphrase: 'DanielRulz'}
module.exports = {
sendiOSNotifications : function( p_token,p_data,p_text){
var apnConnection = new apn.Connection(options);
var myDevice = new apn.Device(p_token);
var note = new apn.Notification();
note.expiry = Math.floor(Date.now() / 1000) + 3600; // Expires 1 hour from now.
note.badge = 1;
note.sound = "ping.aiff";
note.alert = p_text;
note.payload = {'addtionalData': p_data, 'field2': 'value'};
apnConnection.pushNotification(note, myDevice);
}
}
Xcode part
1. Go to the PROJECT build settings
2. Change the "Code Signing" section to what you need (Distribution/Developer)
%SCREEN_SHOT%
1. Go to the PROJECT build settings
2. Change the "Code Signing" section to what you need (Distribution/Developer)
%SCREEN_SHOT%
3. Go to the TARGET build settings
4. Change the "Code Signing" section to what you need (Distribution/Developer)
%SCREEN_SHOT%
4. Change the "Code Signing" section to what you need (Distribution/Developer)
%SCREEN_SHOT%