Iphone 应用程序退出时自动增加ApplicationBadgeNumber

Iphone 应用程序退出时自动增加ApplicationBadgeNumber,iphone,Iphone,程序员们,我对objective C还不熟悉 我正在处理本地通知任务,我的任务是当用户退出应用程序并且不再运行应用程序时,假设有一天,那么应用程序图标徽章号应该自动增加到一。如果它在48小时内没有运行,那么它应该递增并变为2(意味着我必须重复通知),以此类推 我正在为此使用本地通知。我是这样做的: - (void)applicationWillResignActive:(UIApplication *)application { [self launchNotification]; }

程序员们,我对objective C还不熟悉

我正在处理本地通知任务,我的任务是当用户退出应用程序并且不再运行应用程序时,假设有一天,那么应用程序图标徽章号应该自动增加到一。如果它在48小时内没有运行,那么它应该递增并变为2(意味着我必须重复通知),以此类推

我正在为此使用本地通知。我是这样做的:

- (void)applicationWillResignActive:(UIApplication *)application 
{
    [self launchNotification];
}


-(void)launchNotification
{
    NSDate *todaydate = [NSDate date];
    NSDate *firedates = [todaydate dateByAddingTimeInterval:10.0];

    UILocalNotification *localNotif = [[UILocalNotification alloc] init];
    if (localNotif == nil)
        return;
    localNotif.fireDate = firedates;
    localNotif.timeZone = [NSTimeZone defaultTimeZone];
    NSDateComponents *dateComps = [[NSDateComponents alloc] init];

    NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];
    NSDateComponents *timeComponents = [calendar components:( NSHourCalendarUnit |     NSMinuteCalendarUnit | NSSecondCalendarUnit)
                                                   fromDate:firedates];

    [dateComps setHour:[timeComponents hour]];
    [dateComps setMinute:[timeComponents minute]];
    [dateComps setSecond:[timeComponents second]+10];

    localNotif.repeatInterval = NSSecondCalendarUnit;

    localNotif.soundName = UILocalNotificationDefaultSoundName;

    // Specify custom data for the notification
    //NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"someValue" forKey:@"someKey"];
    //localNotif.userInfo = infoDict;

    // Schedule the notification
    localNotif.applicationIconBadgeNumber = +1;
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
    [localNotif release];
}

我工作了很长时间,找不到出路。

这里面有什么问题吗?我想你不能这样做,因为本地通知本身不能触发另一个通知。您需要一段代码来运行并发出新通知。如果你的应用程序没有运行(前台或后台),那么你的代码将无法运行。实际上,我不想在通知时显示警报或消息。重复我想要的,每次重复通知后,应用程序图标标识号应为1,因为你知道我们可以重复通知,所以我想做的是在每次重复通知时增加应用程序图标徽章编号。请告诉我如何在每10秒后重复通知。