现在的位置: 首页 > 综合 > 正文

Swift 取消本地通知

2019年09月05日 ⁄ 综合 ⁄ 共 343字 ⁄ 字号 评论关闭

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++

}

抱歉!评论已关闭.