swift中的本地通知ios

时间:2016-02-16 22:38:28

标签: ios xcode swift notifications

UiApplication.sharedApplication().scheduleLocalNotifications(notification)行给出了以下错误value of type 'uiapplication' has no member ' schedulelocalnotification'

我该如何解决这个问题?

import UIKit

class SchermataIniziale:UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()

  let notification = UILocalNotification()

    if #available(iOS 8.2, *) {
        notification.alertTitle = "Mille Favole"
    } else {
        // Fallback on earlier versions
    }

    notification.alertBody = "Ricordati di leggere la favola questa sera"

    notification.fireDate = NSDate(timeIntervalSinceNow: 10)

    notification.applicationIconBadgeNumber = 1

    notification.timeZone = NSTimeZone.defaultTimeZone()

    notification.soundName = UILocalNotificationDefaultSoundName

    UIApplication.sharedApplication().scheduleLocalNotifications(notification)

    //showinitial = false

    // Do any additional setup after loading the view.

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.

}

1 个答案:

答案 0 :(得分:2)

您需要致电scheduleLocalNotification而不是scheduledLocalNotification

示例:

UIApplication.sharedApplication().scheduleLocalNotification(localNotification)

见这里:use