Mohsinali Matiya
Mohsinali Matiya

Reputation: 66

How to set Local Notification repeat interval on Prayer time everyday different times?

In local notifications there is repeatInterval property where we can put the unit repeat intervals for minute, hour, day, week, year, etc.

I want that repeat interval on Prayer time hours and every day same process.

So every Prayer time hours the local notification comes.

Prayer time is everyday different times

How do I do that?

Upvotes: 1

Views: 779

Answers (1)

Simply try this :

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];

Hope it will work for you.

Upvotes: 0

Related Questions