我是 iphone 新手。我正在使用以下代码,这里本地通知不会在 10 秒内触发,并且重复间隔也不起作用,它不会每秒显示通知。在 1 分钟的触发呼叫和同样的方式重复间隔每分钟工作一次。如何将重复间隔设置为每 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];
}