Created
October 9, 2012 04:36
-
-
Save edwardsharp/3856633 to your computer and use it in GitHub Desktop.
#urbanairship
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
document.addEventListener("deviceready", function() { | |
// BEGIN UA PUSH NOTIFICATION INIT | |
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) { | |
if (DEBUG) { 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) { | |
if (DEBUG) { 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) { | |
if (DEBUG) { console.log("The user formerly known as " + alias); } | |
}); | |
}); | |
*/ | |
// Check if push is enabled | |
push.isPushEnabled(function (enabled) { | |
if (enabled) { | |
if (DEBUG) { console.log("Push is enabled! Fire away!"); } | |
} | |
}) | |
if (DEBUG) { console.log("-----window.pushNotification.registrationCallback: " + window.pushNotification.registrationCallback); } | |
// END UA PUSH NOTIFICATION INIT | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment