天天看点

Swift 取消本地通知

var notifyCancel = UILocalNotification()
var notifyArray=UIApplication.sharedApplication().scheduledLocalNotifications
var i = 0
while(i<notifyArray.count){
    if let notify = notifyArray[i] as? UILocalNotification{
        if let info = notify.userInfo as? Dictionary<String,String> {
           if let s = info["name"] {
              if(name==s){//name is the the one you want cancel
                 notifyCancel = notify
                 break
                 }
              }
            }
     }
           
i++

}