本地通知ios 7 swift

时间:2014-08-29 10:12:24

标签: ios swift notifications

我有按钮执行此操作:

@IBAction func pressed() {
    var notif = UILocalNotification()
    notif.fireDate = NSDate(timeIntervalSinceNow: 5)
    notif.alertBody = "some text"
    UIApplication.sharedApplication().scheduleLocalNotification(notif)
    notif.timeZone = NSTimeZone.defaultTimeZone()
}

我按下它,但没有发生。有什么问题?

1 个答案:

答案 0 :(得分:0)

试试这个:

var localNotification = UILocalNotification()
localNotification.fireDate = NSDate(timeIntervalSinceNow: 5)
localNotification.alertBody = "Bienvenido a Neku!"
localNotification.timeZone = NSTimeZone.defaultTimeZone()
localNotification.applicationIconBadgeNumber = UIApplication.sharedApplication().applicationIconBadgeNumber + 1       UIApplication.sharedApplication().scheduleLocalNotification(localNotification)