この問題を解決するには? これは私のコードです:Objective-C:迷惑 - 私はUILocalNotificationsから毎分約5-6の通知を受け取ります
NSDate *dateToSet = [NSDate dateWithTimeIntervalSinceNow:1.0];
NSString *message = @"Test notification";
UILocalNotification *warningNotification = [[UILocalNotification alloc] init];
warningNotification.fireDate = dateToSet;
warningNotification.timeZone = [NSTimeZone defaultTimeZone];
warningNotification.alertBody = message;
warningNotification.hasAction = NO;
warningNotification.userInfo = nil;
warningNotification.repeatInterval = NSCalendarUnitDay;
warningNotification.soundName = nil;
[[UIApplication sharedApplication] scheduleLocalNotification:warningNotification];
そして、私のAppDelegate.m(didFinishLaunchingWithOptions):
UIUserNotificationType types = UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
UIUserNotificationSettings *mySettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];
if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
}
[[UIApplication sharedApplication] scheduledLocalNotifications];
[application registerForRemoteNotifications];
この行は何をしていますか? '[[UIApplication sharedApplication] scheduledLocalNotifications];'? – Avi
実際、私はUILocalNotificationsを初めて使っています。これは私の新しいアプリで初めて使用しています。インターネット上のチュートリアルからこれらのコードを追加しました。 –