0 Replies
      Latest reply on Jan 13, 2020 8:42 PM by mohamed.t
      mohamed.t Level 1 Level 1 (0 points)



        Currently I cannot clear a local notification in app (example: A reminder) which i scheduled from Notification Service Extension (NSE).


        i've tired clearing using the following APIs,


        NSArray *ids = @[@"Notify_from_app",@"Notify_from_extension"]; 
        UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];    
        [center removeAllDeliveredNotifications]; 
        [center removePendingNotificationRequestsWithIdentifiers:ids]; 


        The above code works fine, when i try to clear a notification in NSE, which is scheduled from the same NSE. (if i try to clear from app, i can't)


        FYI, i'm able to clear all the notifications using the following code. (but my goal is to clear the notification using identifiers, a specific notification)


        UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; 
        [center removeAllDeliveredNotifications]; 
        [center removeAllPendingNotificationRequests]; 



        As per apple's documentation, the currentNotficationCenter object supports app extensions as well, that's why I'm able to schedule a local notifications from there.

        • May be the currentNotificationCenter object for the app is not equal to the currentNotificationCenter object of NSE.
          • This makes more sense because both have a separate container. (That's why we are not able to directly access the app's container from NSE.)
        • Can i make a copy of the object in coredata and retrieve it in app to clear the notification?
          • This dosen't feel like a good practice.


        I'm looking for a proper solution to clear the reminders, Please help me out.