It seems that the function deviceTokenSuccess(e) is not being called after registerForPushNotifications. I followed the example but I can't get it to work.
Herewith my code:
// Alloy.Globals.someGlobalFunction = function(){}; var deviceToken = null; // Check if the device is running iOS 8 or later if (Ti.Platform.name == "iPhone OS" && parseInt(Ti.Platform.version.split(".")[0]) >= 8) { function registerForPush() { Ti.Network.registerForPushNotifications({ success: deviceTokenSuccess, error: deviceTokenError, callback: receivePush }); // Remove event listener once registered for push notifications Ti.App.iOS.removeEventListener('usernotificationsettings', registerForPush); }; // Wait for user settings to be registered before registering for push notifications Ti.App.iOS.addEventListener('usernotificationsettings', registerForPush); // Register notification types to use Ti.App.iOS.registerUserNotificationSettings({ types: [ Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT, Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND, Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE ] }); } else { // For iOS 7 and earlier Ti.Network.registerForPushNotifications({ // Specifies which notifications to receive types: [ Ti.Network.NOTIFICATION_TYPE_BADGE, Ti.Network.NOTIFICATION_TYPE_ALERT, Ti.Network.NOTIFICATION_TYPE_SOUND ], success: deviceTokenSuccess, error: deviceTokenError, callback: receivePush }); } // Process incoming push notifications function receivePush(e) { alert('Received push: ' + JSON.stringify(e)); } // Save the device token for subsequent API calls function deviceTokenSuccess(e) { deviceToken = e.deviceToken; } function deviceTokenError(e) { alert('Failed to register for push notifications! ' + e.error); }