Created
August 9, 2012 17:18
-
-
Save ericholscher/3306077 to your computer and use it in GitHub Desktop.
Urban Airship Phonegap Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
push = window.pushNotification; | |
// Callback for when a device has registered with Urban Airship. | |
// https://docs.urbanairship.com/display/DOCS/Server%3A+Android+Push+API#ServerAndroidPushAPI-Registration | |
push.registerEvent('registration', function (id) { | |
console.log("Registered with ID: " + id); | |
}; | |
// Callback for when the app is running, and recieves a push. | |
push.registerEvent('push', function (push) { | |
console.log("Got push: " + push.message) | |
}); | |
// Set tags on a device, that you can push to | |
// https://docs.urbanairship.com/display/DOCS/Server%3A+Tag+API | |
push.setTags(["loves_cats", "shops_for_games"], function () { | |
push.getTags(function (obj) { | |
obj.tags.forEach(function (tag) { | |
console.log("Tag: " + tag); | |
}); | |
}); | |
}); | |
// Set an alias, this lets you tie a device to a user in your system | |
// https://docs.urbanairship.com/display/DOCS/Server%3A+iOS+Push+API#ServeriOSPushAPI-Alias | |
push.setAlias(["awesomeuser22"], function () { | |
push.getAlias(function (alias) { | |
console.log("The user formerly known as " + alias) | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment