Hi I am trying to remove a notification from the notification center when my app is on the background and a silent push arrives. It works fine if the app is in Foreground or connected to debugger.
However when the apps is on background it doesn't work. I'm using in removeDeliveredNotificationsWithIdentifiers
inside didReceiveRemoteNotification
. Any advice ?
Thank you
[center getDeliveredNotificationsWithCompletionHandler:^(NSArray<UNNotification *> * _Nonnull notifications) {
for (UNNotification* notification in notifications)
{
NSDictionary* ui = notification.request.content.userInfo;
if ([ui[@"activityId"] isEqualToString:activityId])
{
[center removeDeliveredNotificationsWithIdentifiers:@[notification.request.identifier]];
}
}
completionHandler(UIBackgroundFetchResultNoData);
}];