#node-urban-airship
Simple wrapper for the Urban Airship API.
##Installation
npm install urban-airship
var UA = require("urban-airship");
var ua = new UA("<api key>", "<api secret key>", "<api master key>");
##Usage
Sample API Calls
-
Register a device
ua.registerDevice("< token >", function(error) {...});
-
Create payloads for the push notification API needed.
Information available here. http://urbanairship.com/docs/push.html
Push Notification Examples:
a) "/api/push/" var payload0 = { "device_tokens": [ The device or device ids to send the message to ], "aps": { "alert": "Calling Urban Airship!", "badge": 2 } }; ua.pushNotification("/api/push", payload0, function(error) {....}); b) "/api/push/broadcast/" var payload1 = { "aps": { "badge": 15, "alert": "Calling Urban Airship!", "sound": "cat.caf" }, "exclude_tokens": [ "device token you want to skip", "another device token you want to skip" ] }; ua.pushNotification("/api/push/broadcast/", payload1, function(error) {.....});
-
Unregister a device.
ua.unregisterDevice("< token >", function(error) {....});