(UILocalNotification)iPhone报警应用程序 - 通知问题

时间:2013-02-22 20:44:06

标签: iphone notifications uilocalnotification alarm

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

警报通过通知中心

但是,如果闹钟设置为激活> 8小时后警报通知不会激活

有人知道设置通知是否有时间限制?

是否将应用程序置于前台

我真的很感激一些想法或建议,我们必须在一天内重新提交苹果

谢谢!

-(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 个答案:

没有答案