Problem:
I am not receiving subscription changes (notifications) to private
and shared databases
, when the device is in Do Not Disturb Mode (even when the app is in foreground).
Note:
When device is not in Do Not Disturb mode, I receive subscription changes as and when they occur.
Code:
Registering remote notifications:
application.registerForRemoteNotifications()
Database subscriptions:
let subscription = CKDatabaseSubscription(subscriptionID: "Test")
let notificationInfo = CKNotificationInfo()
notificationInfo.shouldSendContentAvailable = true
subscription.notificationInfo = notificationInfo
Receiving Notification:
func application(_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable : Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
let notification = CKNotification(fromRemoteNotificationDictionary: userInfo)
dataService.receivedCloudKitNotification(notification,
completionBlock: completionHandler)
}
Since I am not using sound / badge / alert / carplay (UNAuthorizationOptions
), I had opted for the above method.
My Assumption:
- I was assuming that Do Not Disturb would be applicable only for anything that would alert the user visually / or through sound.
- I was assuming silent notifications are for data changes and wouldn’t be affected by it. (Just like they don’t require any authorisation)
Questions:
- Am I missing any steps for the above mentioned problem ?
- On a different scenario, When app is not in Do Not Disturb mode but Background Refresh is turned off for the app I don’t receive subscription changes notifications though the app is in foreground.