消息推送相关

2021-12-02  本文已影响0人  独孤流

iOS 点击其中一个通知会清空掉通知栏的所有通知问题
iOS 本地推送(Local Push)
ios本地通知UILocalNotification以及区分谁触发了通知
将已经发送的通知清除

// 获取所有已发送的通知
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
UNAuthorizationOptions    option       = UNAuthorizationOptionBadge |
                                             UNAuthorizationOptionSound |
                                             UNAuthorizationOptionAlert;
[center requestAuthorizationWithOptions:option completionHandler:^(BOOL granted, NSError * _Nullable error) {
        if (granted) {
             [center  getPendingNotificationRequestsWithCompletionHandler:^(NSArray<UNNotificationRequest *> * _Nonnull requests) {

                }];
       }
        
        

// 删除指定id的
[[UNUserNotificationCenter currentNotificationCenter] removeDeliveredNotificationsWithIdentifiers:removeLocalIdList];
                [[UNUserNotificationCenter currentNotificationCenter] removePendingNotificationRequestsWithIdentifiers:removeLocalIdList];
// 全部删除
//            [[UNUserNotificationCenter currentNotificationCenter] removeAllDeliveredNotifications];
//            [[UNUserNotificationCenter currentNotificationCenter] removeAllPendingNotificationRequests];
上一篇 下一篇

猜你喜欢

热点阅读