我正在尝试在用户注册后安排一些通知三个月。虽然,首先我需要在注册后的第一个早晨定义。 你能帮帮我吗?
答案 0 :(得分:0)
安排本地通知。
let localNotif = UILocalNotification()
let calendar = NSCalendar.autoupdatingCurrentCalendar()
let dateComps = NSDateComponents()
dateComps.day = registrationDate.day
dateComps.month = registrationDate.month
dateComps.year = registrationDate.year
dateComps.hour = 9
dateComps.minute = 0
let itemDate = calendar.dateFromComponents(dateComps)
localNotif.fireDate = itemDate.dateByAddingTimeInterval(24.0 * 60.0 * 60.0)
localNotif.timeZone = NSTimeZone.defaultTimeZone()
localNotif.alertBody = "Good Morning new user!"
localNotif.alertAction = "View details"
localNotif.alertTitle = "Good morning"
localNotif.soundName = UILocalNotificationDefaultSoundName
localNotif.applicationIconBadgeNumber = 1
UIApplication.sharedApplication().scheduleLocalNotification(localNotif)