0

我正处于开发 iPhone 警报应用程序的最后阶段

警报通过通知中心工作。

适用于短时间延迟(比如 2 小时)

早上不上班(长时间延迟8小时)

它似乎在没有互联网接入的手机上也能正常工作?

是否有某种自动时间更新/同步会干扰警报功能?

是否延迟了 8 小时以上的时间来抵消通知?

应用程序是否需要在前台?

所以警报可以在短时间延迟,但不是在早上(当它意味着!)

我们将很快向 Apple 提交更新!

非常感谢你,

亨利(澳大利亚)

-(void)addLocalNotification:(myAlarmData *)ma WeekDay:(int)mweekday
{
    UILocalNotification *noti = [[UILocalNotification alloc] init];

    NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

    NSDate *now = [NSDate date];

    NSDateComponents *dcom = [gregorian components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit |NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit | NSWeekdayCalendarUnit) fromDate:now];

    [dcom setWeekday:mweekday];
    [dcom setHour:ma.mHour];
    [dcom setMinute:ma.mMinute];
    [dcom setSecond:0];


    NSDate *fireDate = [gregorian dateFromComponents:dcom];

    noti.fireDate = fireDate;
    noti.timeZone = [NSTimeZone localTimeZone];
    noti.alertBody = [NSString stringWithFormat:@"Wake up %@!", [GlobalData gSettings].name];
    noti.soundName = [NSString stringWithFormat:@"%@.caf", ma.soundName];
    noti.alertAction = @"OK";

    noti.repeatInterval = NSWeekCalendarUnit;

    noti.userInfo = [[[NSDictionary alloc] initWithObjectsAndKeys:
                      ma.mid, @"mid",
                      [NSString stringWithFormat:@"%d", mweekday], @"day",
                      ma.soundName, @"sound",
                     [NSString stringWithFormat:@"%d", ma.snooze], @"snooze",
                      ma.title, @"title",
                      @"Close", @"action",
                      @"real", @"more",
                      nil] autorelease];

    [[UIApplication sharedApplication] scheduleLocalNotification:noti];

    [noti release];
    [gregorian release];
}
4

0 回答 0