当前位置: 动力学知识库 > 问答 > 编程问答 >

ios - How to set a custom local notification for everyday at a given time like a bible verse notification eachday

问题描述:

Example : on 22/7/15 at 5pm fire notification "Hy how r u " And on 23/7/15 at 5pm get notification " how u feeling" likewise in everyday how i fire local notification that i assigned for each day , how to assign custom notification for each day?

网友答案:

You can use repeatInterval property of UILocalNotification and schedule a notification like this :

var notification = UILocalNotification()
notification.alertBody = "text that will be displayed for notification" 
notification.fireDate = NSDate()  
notification.soundName = UILocalNotificationDefaultSoundName 
notification.repeatInterval = NSCalendarUnit.NSDayCalendarUnit 
UIApplication.sharedApplication().scheduleLocalNotification(notification)

But, if you want a notification for different message every time, you will have to create a new notification for every new message and then you can schedule them for every day. You can set notification for some number of days only. Another possible approach is to use Push Notifications

分享给朋友:
您可能感兴趣的文章:
随机阅读: