Cancel UILocalNotification

后端 未结 10 937
余生分开走
余生分开走 2020-11-27 12:53

I have a problem with my UILocalNotification.

I am scheduling the notification with my method.

- (void) sendNewNoteLocalReminder:(NSDate *)date  a         


        
10条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 13:44

    Swift version to cancel particular "Local Notification" using userinfo.:

    func cancelLocalNotification(UNIQUE_ID: String){
    
            var notifyCancel = UILocalNotification()
            var notifyArray = UIApplication.sharedApplication().scheduledLocalNotifications
    
            for notifyCancel in notifyArray as! [UILocalNotification]{
    
                let info: [String: String] = notifyCancel.userInfo as! [String: String]
    
                if info[uniqueId] == uniqueId{
    
                    UIApplication.sharedApplication().cancelLocalNotification(notifyCancel)
                }else{
    
                    println("No Local Notification Found!")
                }
            }
        }
    

提交回复
热议问题