Skip to content

Instantly share code, notes, and snippets.

@arockwell
Created May 8, 2012 01:00
Show Gist options
  • Select an option

  • Save arockwell/2631776 to your computer and use it in GitHub Desktop.

Select an option

Save arockwell/2631776 to your computer and use it in GitHub Desktop.
node redis proof of concept
watch_redis = ->
redis.blpop "test", 0, (err, data) ->
noti = JSON.parse(data[1])
console.log("message: #{noti.message} device_ids: {noti.device_ids}")
apnsSend(noti.message, noti.device_ids)
process.nextTick(watch_redis)
watch_redis()
apnsOptions = {
cert: '/Users/arockwell/dev/node_push_notification/apns-teamstream-dev-cert.pem',
certData: null,
key: '/Users/arockwell/dev/node_push_notification/apns-teamstream-dev-cert.pem',
keyData: null,
passphrase: null,
gateway: 'gateway.sandbox.push.apple.com',
port: 2195,
enhanced: true,
errorCallback: undefined,
cacheLength: 5
};
apnsConnection = new apns.Connection(apnsOptions);
apnsSend = (message, device_ids) ->
for device_id in device_ids
noti = new apns.Notification();
noti.alert = message
noti.device = new apns.Device(device_id)
console.log("Sending notification message: #{message} device: #{noti.device}")
apnsConnection.sendNotification(noti);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment