How To Use UILocalNotification In Swift

前端 未结 6 1921
温柔的废话
温柔的废话 2021-02-06 01:59

I am trying to figure out how to setup a UILocalNotification in swift but I am not having a lot of luck. I am trying this:

var notification = UILocalNotification         


        
6条回答
  •  执笔经年
    2021-02-06 02:16

    In Swift, to cancel the particular local notification using Unique Key:

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

提交回复
热议问题