Mohit Jain Mohit Jain - 9 days ago 5
iOS Question

Get Appcelerator Titanium push notification while App in foreground in IOS only

I have implemented Appcelerator Titanium push notification in my application (Android and IOS) for Message Receiving :

I am receiving notification in android on both when app is in background and foreground. I am using below property in android to show notification when app is in foreground (CloudPush.showTrayNotificationsWhenFocused = true;)

Problem: I am facing problem in IOS (version 9.1 iPhone5) while receiving Notification when app is in foreground.
When app is in background, notification is showing in notification bar but when app is in foreground notification is not showing in notification bar for IOS.

Please Can any one help me, how can I get notification when app is in foreground for IOS.

Thanks

Answer

Take a look at the Documentation for push notifications.

Inside the documentation there is a callback:

    Ti.Network.registerForPushNotifications({
        success: deviceTokenSuccess,
        error: deviceTokenError,
        callback: receivePush
    });

This links to this code:

// Process incoming push notifications
function receivePush(e) {
    alert('Received push: ' + JSON.stringify(e));
}

This will trigger also when inside the app.

Please follow the link above to set it up correctly. It might not work otherwise.