更新时间:2023-12-03 16:18:34
如果您的应用程序支持 iOS 10 及更高版本,那么您应该能够使用 UNUserNotificationCenter
类检索待处理的通知.
If your application supports iOS 10 and above, then you should be able to retrieve pending notifications using the UNUserNotificationCenter
class.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[UNUserNotificationCenter currentNotificationCenter] getPendingNotificationRequestsWithCompletionHandler:^(NSArray<UNNotificationRequest *> * _Nonnull requests) {
for (UNNotificationRequest *request in requests) {
NSDictionary *userInfo = request.content.userInfo;
NSLog(@"push user info: %@", userInfo);
// Handle the payload here.
}
}];
return YES;
}