iPhone Alarm App神秘失活(UILocalNotification)

时间:2013-02-22 08:39:49

标签: iphone ios notifications alarm

我正处于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];
}

0 个答案:

没有答案