美文网首页
消息推送相关

消息推送相关

作者: 独孤流 | 来源:发表于2021-12-02 22:31 被阅读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];
    

    相关文章

      网友评论

          本文标题:消息推送相关

          本文链接:https://www.haomeiwen.com/subject/mzhuxrtx.html