2016-09-06 37 views
1

在本地通知中有repeatInterval屬性,我們可以將分鐘,小時,星期,星期,年份等單位重複間隔。如何在禱告時間每天不同的時間設置本地通知重複間隔?

我希望禱告時間和每天的相同過程的重複時間間隔。

所以每個禱告時間小時當地通知來。

祈禱時間每天都在不同時間

我該怎麼做?

+0

我建議爲每天的祈禱小時創建一個本地通知,重複間隔爲1天。 – Larme

+0

@Larme,據我所知,祈禱時間每天都在變化,至少其中一些是基於日落/日出之類的。 – jcaron

+0

@jcaron你是對的 –

回答

0

只要試試這個:

NSCalendar *calen = [NSCalendar autoupdatingCurrentCalendar] ; 
NSDateComponents *components = [calen components:(NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute) fromDate:[NSDate date]]; 
[components setHour:9]; 
[components setMinute:30]; 
[components setSecond:00]; 

UILocalNotification *notif = [[UILocalNotification alloc]init]; 
notif.fireDate = [calen dateFromComponents:components]; 
notif.repeatInterval = NSCalendarUnitDay; 
[notif setAlertBody:@"Its prayer time..."]; 
[[UIApplication sharedApplication] scheduleLocalNotification:notif]; 

希望它會爲你工作。

+0

但每天的時間是不同的,每天安排 –

+0

是的,我已經祈禱了時間計算方法。每天不同時間也得到時間 –

+0

? –

相關問題