ios - 如何设置每两周一次本地通知

标签 ios objective-c uilocalnotification localnotification

如何每两周触发一次本地通知?

我所做的是:

UILocalNotification *localNotification = UILocalNotification.new;
localNotification.repeatInterval = 14;
localNotification.fireDate = [NSDate dateWithTimeInterval:10 sinceDate:notificationDate];
localNotification.alertBody = notificationMessage;
localNotification.alertAction = @"Open";
localNotification.category = @"default_category";
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

最佳答案

尝试下面的代码:

UILocalNotification *notification = [[UILocalNotification alloc]init];
notification.userInfo = @{@"notification_identifier":@"After14Days"};
notification.fireDate = [[NSDate date] dateByAddingTimeInterval:(60*60*24*14)];
notification.alertBody = @"Text to display";
notification.repeatInterval = NSCalendarUnitDay;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];

关于ios - 如何设置每两周一次本地通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38870576/

相关文章:

ios - 发送电子邮件时出现问题

ios - 作为开发人员了解 Homekit

java - Objective-C NSError 和 Java 错误

ios - 创建新 View 后 iOS 应用程序崩溃

ios - clipsToBounds 仅垂直

ios - 声明本地通知的标题、副标题和正文

ios - 本地通知覆盖iOS 9中的远程通知(可行通知)设置?

objective-c - 为 CoreAudio 设置效果音频单元

ios - 如何从 VoiceOver 中排除 UIButton?

swift - 本地通知是否需要 iOS 上的用户权限?