Get Appcelerator Titanium push notification while

2019-08-14 18:19发布

问题:

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

回答1:

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.