Iphone 以自定义时间间隔显示本地通知

Iphone 以自定义时间间隔显示本地通知,iphone,Iphone,我是iphone新手。我正在使用以下代码,这里的本地通知在10秒内不会发出,重复间隔也不起作用,它不会在每秒钟显示通知。在1分钟的firedate呼叫后,重复间隔每分钟工作一次。如何将重复间隔设置为每15秒。如果有人知道这一点,请帮助我 - (void)applicationDidEnterBackground:(UIApplication *)application { NSLog(@"1"); NSTimeInterval interval = 10; NSDate

我是iphone新手。我正在使用以下代码,这里的本地通知在10秒内不会发出,重复间隔也不起作用,它不会在每秒钟显示通知。在1分钟的firedate呼叫后,重复间隔每分钟工作一次。如何将重复间隔设置为每15秒。如果有人知道这一点,请帮助我

- (void)applicationDidEnterBackground:(UIApplication *)application {
    NSLog(@"1");

   NSTimeInterval interval = 10;
    NSDate *alertTime = [NSDate dateWithTimeIntervalSinceNow:interval];
    UIApplication* app = [UIApplication sharedApplication];
    UILocalNotification* notifyAlarm = [[UILocalNotification alloc] init];
    if (notifyAlarm){
        notifyAlarm.fireDate = alertTime;

        notifyAlarm.alertAction = @"Message";
        notifyAlarm.alertBody = @"Alert";
        notifyAlarm.hasAction = YES;
        notifyAlarm.timeZone = [NSTimeZone defaultTimeZone];

        notifyAlarm.repeatInterval = NSSecondCalendarUnit;
      //  timer = [[NSTimer alloc]initWithFireDate:alertTime interval:interval target:self selector:@selector(sendRequest) userInfo:nil repeats:YES];

        [app scheduleLocalNotification:notifyAlarm];

        }

您需要在appDelegate中实现这一点,以便在应用程序运行时通知起作用

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
    //do something
}

你有什么不清楚的地方?