私はiphoneを初めて使用しています。以下のコードで作業しています。ここでは、ローカル通知が10秒で起動せず、繰り返し間隔も機能しません。1秒ごとに通知が表示されません。同じように、繰り返し間隔は 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];
}