IOS - Enable/disable A Group Of Notifications Based On Switch Value
I have a bunch of notifications in my iOS app which can be placed in groups:
- Group 1: "Events" -> 2 kind of notifications
- Group 2: "Promotions" -> 3 kind of notifications .....
In my setting screen I have a switch for each notification group. I want to enable disable the group of notification based on the value of the respective switch : ex: Events switch is turned off so I don't want to receive the 2 type of notifications of this group.
It easily handled when the app is on foreground by using the completionHandler of the function:
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)
But I can't find a way to block those notification when the app is in background.
I read that to deal with background notifications like that. I have to store in my own server the value of the switches for each user and send or not the notification based on the value on the server.
It is the right way to do that or am I missing something in my app.
You can't interact with notifications that are sent while your app is not active, they will be received either way since they have been designed that way.
The fact that you can do that while the app is active is actually aimed at developers to allow them to use custom notification handling while the app is active instead of a method to filter them.
The best way to handle that is the one you proposed, the backend should filter what types of notifications to send to the user, and send only those to the user.
- → Function Undefined in Axios promise
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Click to navigate on mobile devices
- → Playing Video - Server is not correctly configured - 12939
- → How to allow api access to android or ios app only(laravel)?
- → Axios array map callback
- → Access the Camera and CameraRoll on Android using React Native?
- → Update React [Native] View on Day Change
- → Shopify iOS SDK - issue converting BuyProductVariant to BuyProduct
- → BigCommerce and shopify API
- → Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
- → React Native - Differences between Android and IOS
- → What is the difference between React Native and React?