Pushfication written in Nodejs
CoffeeScript Makefile
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.gitignore
.npmignore
Cakefile
Makefile
README.md
package.json

README.md

node-push

Pushfication written in Nodejs

How to use

pusher = require('node-push')

pusher.configure({
  apn: {
    cert: 'cert.pem'
    key: 'key.pem'
    expiry: 3600 # seconds
    sound: 'ping.aiff'
    useSandbox: false
  }
  baidu: {
    secret: 'your app secret'
  }
  mailgun: {
    domain: 'your-domian.mailgun.org'
    apiKey: 'appkey'
  }
  luosimao: {
    user: 'username'
    apiKey: 'apiKey'
  }
})

pusher.mailgun.send({
  from: 'SKY <sky@your-domain.mailgun.org>'
  to: 'xxx@your-domain.com'
  subject: 'test'
  html: 'html'
  text: 'text'
  'o:testmode': true
}, (err, ret) ->
  console.log err, ret
)

pusher.apn.send({
  deviceToken: 'xxxx'
  alert: 'new message'
  badge: 1
  sound: 'ping.aiff'
  extra: {}
})
pusher.baidu.send({
  messages: JSON.stringify
    title: 'title'
    description: 'desc'
    custom_content:
      badge: 1
  user_id: 'user_id'
})
pusher.luosimao.send({
  mobile: 1111111111
  message: '夏季炎热,注意防暑降温'
}, (err, resp) ->
  console.log err, resp
})

pusher.xiaomi.send({
  description: "发送内容"
  pass_through: 1
  payload: "urlencode%20内容"
  registration_id: 'xiaomi token'
  title: 'today'
  notify_type: 2
  extra: # 额外的数据,key 的用"extra." 开头
    "extra._objectId": "d2ewed4r"
    "extra.objectType": 'reminder'
})

others

mailgun subscribe

pusher.mailgun.subscribe(`listAddress`, {
  subscribed: true
  address: 'your@exmaple.com'
  name: 'yourname'
  description: 'your info'
}, (err, ret) ->
  console.log err, ret
)

API

configure(options)

  • TODO

apns.push(object)

push a message via APNs to certain device. The object include

  • deviceToken: hexed apple device token
  • alert:
  • category:
  • badge:
  • sound:

apns.getInvalidDevices(callback(error, list))

return a list with invalid device's hex

xiaomi.push(object)

push a message via XIAOMI to certain device. The object include

  • registration_id: (string) xiaomi device token
  • description:
  • pass_through:
  • payload:
  • title:
  • notify_type:

xiaomi.getInvalidDevices(callback(error, list))

return a list with invalid device's hex