How to Prevent a Remote Notification from Being Displayed

Can handler not show remote notification when iOS app is killed?

Yes, it's correct.

You cannot catch a remote notification and hide it. The best way to not receive remote notifications is to say no to the permission. If your server send remote notifications you can configure it not to send notifications when you does not want.

Another way to send notifications and not show them is to send "silent notification". It allows you to receive the notification, get its content and do what you want (you have only 30s). I thinks, you can send silent notifications, check content and send a local notification if it needs to, but I'm not sure.

Do not display a remote notification based on custom data

Instead I recommend filtering on your server as sending a notification to all devices (just to omit them from being displayed) has down sides including; extra battery drain and content-available notifications do not work when the user swipes away the app.

You can use mutable-content instead which will fire your UNNotificationServiceExtension but this only works on iOS 10 and you still need to take battery into consideration.

You can get the device's OneSignal player id by calling IdsAvailable where you can store this on your back end. Then you can then use include_player_ids on the create notification REST API call to target only the users who should receive the notification.



Related Topics



Leave a reply



Submit