i getting push notification if app is in foreground for ios device(i checked with version 9.3.5 , 10 and above) …but i want to show that in shade . For android we have “forceShow”: “true” is there anything for ios.
my front end code is here .
Controls the behavior of the notification when app is in foreground. If true and app is in foreground, it will show a notification in the notification drawer, the same way as when the app is in background (and on(‘notification’) callback will be called only when the user clicks the notification). When false and app is in foreground, the on(‘notification’) callback will be called immediately.
In my case, the on('notification') callback makes a request and then a state change in the ui-router, so with the forceShow set to true, I just see a normal notification and it’s user’s choice to click on it and with that executing the callback.
In Android this is working as desired, if you are in a view and you receive a notification, if the user clicks on it it will be forced to change the state in the ui-router
In iOS user doesn’t have that choice(the forceShow option), and the on('notification') callback is always executed and if the user is with the app in foreground, at the moment the notification is received there is a state change.
I don’t think this concept of “if I have the app open and get a notification, only show it on the OS level” exists in iOS - the moment you open the app, all already received and then received notifications while the app is open are handled by the app directly - and the “OS level” notification stuff (notification center basically) is bypassed.
But I am sure you could just handle the notification, show the user inside the app that some “notification event” was pushed onto a stack, and by clicking e.g. a button he can see this notifications and accept them. Think of Whatsapp or Facebook messages inside the Facebook app.
//push notification plugin configuration
var push = PushNotification.init({
android: {
senderID: ConstantsValues.SENDER_ID,
icon: "icon",
forceShow: true
},
ios: {
alert: "true",
badge: "true",
sound: "true",
icon: "icon"
},
});
//push plugin registration event
push.on('registration', function (data) {
console.log('Register ID: ' + data.registrationId);
var deviceRequest = {
registerId: data.registrationId,
deviceType: $rootScope.isAndroid ? 'ANDROID' : 'IOS',
deviceId: window.device.uuid
};
//Get request to register device to our server
CustomService.notificationPush(deviceRequest);
});
//When click notification in bar or a notification is received in foreground
push.on('notification', function (data) {
if($rootScope.isIOS && data.additionalData.foreground) {
//Show modal to user to give him/her choice to travel to the notification state
//custom Modal Service
ModalService
.show('notificationModal.html', 'NotificationModalController', data).then(function (result) {
if(result){
//if user click SHOW NOTIFICATION on Modal
getDetailNotification(data);
}
});
} else {
//Android background or foreground(with forceShow: true) OR iOS background
getDetailNotification(data);
}
});