首页 文章

如何在祷告时间每天不同的时间设置本地通知重复间隔?

提问于
浏览
1

在本地通知中有repeatInterval属性,我们可以将单位重复间隔设置为分钟,小时,日,周,年等 .

我想在祈祷时间和每天同一过程中重复间隔 .

所以每个祷告时间都会有本地通知 .

祷告时间是每天不同的时间

我怎么做?

1 回答

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

    希望它能为你效劳 .

相关问题