I am currently saving a flag to disable notifiations in my user preferences. I use that flag in my didReceieveRemoteNotifications
to show or skip the notification that comes in. However, when my app is in the background it still shows and I believe I have all my methods setup correctly and it's not being hit. Is there a way to catch this notification while app is in the background and skip it from showing?
NSNumber* enabled = [Helper getBooleanPreference:[Config subscriptionsEnabled]];
if(enabled == nil || [enabled integerValue] == 1) {
completionHandler(UIBackgroundFetchResultNewData);
}
From Apple documentation
The sending of a silent notification requires a special configuration of the notification’s payload. If your payload is not configured properly, the notification might be displayed to the user instead of being delivered to your app in the background. In your payload, make sure the following conditions are true:
The payload’s aps dictionary must include the content-available key with a value of 1.
The payload’s aps dictionary must not contain the alert, sound, or badge keys.
So your push should contain content-available with value 1 and not contain alert, sound, or badge keys.
In that case you have to show UILocalNotification
if you want to notify the user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With