您好我正在尝试安排本地通知在工作日上午9点(星期一)开火,并且似乎无法找到有关如何执行此操作的任何文档。到目前为止,这是我的代码:
@IBAction func scheduleLocal(sender: UIButton) {
guard let settings = UIApplication.sharedApplication().currentUserNotificationSettings() else { return
}
if settings.types == .None {
let ac = UIAlertController(title: "Cant Schedule", message: "No Permission", preferredStyle: .Alert)
ac.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))
presentViewController(ac, animated: true, completion: nil)
return
}
let notification = UILocalNotification()
notification.fireDate = NSDate()
notification.alertBody = "Come Exercise"
notification.alertAction = "Exercise Time"
notification.soundName = UILocalNotificationDefaultSoundName
notification.userInfo = ["customField1": "w00t"]
UIApplication.sharedApplication().scheduleLocalNotification(notification)
}
并在viewDidLoad中:
let notificationSettings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(notificationSettings)
答案 0 :(得分:0)
这是我的课程示例,您可以根据需要使用它,我也支持阿拉伯语,将阿拉伯语翻译成英语。
/**
The semantic version.
@property VERSION
@type String
@default '2.4.1'
@static
@public
*/
Ember.VERSION = '2.4.1';