liam923
liam923

Reputation: 1021

Get all push notifications received since app was last open

I'm creating an iOS 10 app using Xcode 8 and CloudKit. When the app loads, is there any way to read all push notification that have been sent since the last time the app was running?

Upvotes: 8

Views: 3533

Answers (2)

Quang Vĩnh Hà
Quang Vĩnh Hà

Reputation: 524

You can call the following function, request contains all notifications delivered

[[UNUserNotificationCenter currentNotificationCenter]
getDeliveredNotificationsWithCompletionHandler:^(NSArray<UNNotificationRequest
 _Nonnull requests) {
           NSLog(@"");
   }];

Upvotes: 7

Dhaval Patel
Dhaval Patel

Reputation: 726

from ios 10.x we can get pending and delivered notification information using UNUserNotificationCenter

you with a list of the app’s notifications that are still displayed in Notification Center using below function

func getDeliveredNotifications(completionHandler: @escaping ([UNNotification]) -> Void)

refrer below link for more details

Upvotes: 1

Related Questions