我是 iOS 新手,在显示本地通知方面遇到问题。
下面是我的代码。
AppDelegate.m
-(void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings{
}
在 viewDidLoad()
defaultsnotification = [NSUserDefaults standardUserDefaults];
UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
UIUserNotificationSettings *mySettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:0]; //Enter the time here in seconds.
localNotification.alertBody = @"app Update Available";
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.repeatInterval = NSCalendarUnitDay; //Repeating instructions here.
localNotification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
通过使用此代码通知在一分钟后调用。但我需要在 24 小时后给它打电话。
我怎样才能做到这一点?
提前致谢!
最佳答案
请更新以下内容-
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:(24*60*60)];
关于ios - 如何在Objective C中一天或24小时后显示本地通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42646561/