Skip to content

Instantly share code, notes, and snippets.

@joshjensen
Created May 28, 2014 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshjensen/90d0cb4edadb92ef57bb to your computer and use it in GitHub Desktop.
Save joshjensen/90d0cb4edadb92ef57bb to your computer and use it in GitHub Desktop.
Sample Push Handler.
CloudPush.retrieveDeviceToken({
success: function(_data) {
Ti.API.info("ACS.init @success");
exports.deviceToken = _data.deviceToken;
Ti.App.Properties.setString("PUSH_DEVICETOKEN", _data.deviceToken);
CloudPush.addEventListener('callback', function (evt) {
if (appActive) {
exports.pushRecieved(evt);
} else {
var activeInterval = setInterval(function() {
if (appActive) {
exports.pushRecieved(evt);
clearInterval(activeInterval);
}
}, 500);
}
Ti.API.info(JSON.stringify(evt));
});
},
error: function(_data) {
Ti.API.info("ACS.init @error");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment