Hi,
I used Ti SDK.3.4.0.
I have one problem. Here is my scenario
Scenario 1 I got the notification message. I click the notification. App is open and "callback" function is working. So, i got notification message. this scenario is ok.
Scenario 2 I got the notification message. I don't click the notification. I open the app directly. In this case "callback" function is not working. How to know the notification message, when directly open the application?
Here is my code:
var app = []; // start new code // 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 }); } function deviceTokenError(e) { alert('Failed to register for push notifications! ' + e.error); }; function deviceTokenSuccess(e){ Ti.API.info("Receive: " + JSON.stringify(e)); //store deviceToken in variable app.DEVICE_ID = e.deviceToken; Ti.API.info("Push notification device token is: " + app.DEVICE_ID ); }; function receivePush(e){ //do something with the data from Pushwoosh Ti.API.info("Receive: " + JSON.stringify(e)); };Thanks, Thet Paing