0
這是我的本地通知代碼,我每天使用[localNotification setRepeatInterval:NSCalendarUnitDay];
獲得通知,現在我想在日期和時間到期後使用結束日期和時間來停止或取消通知。我應該在那裏實施,任何人都請解釋。在iOS中使用本地通知設置提醒目標C
NSString *startdate = @"10-12-2016 07:00 am";
NSString *enddate = @"14-12-2016 07:00 am";
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = startdate;
localNotification.alertBody = [NSString stringWithFormat:@"%@ ",self.nameTextField.text];
localNotification.soundName = @"bell_tree.mp3";
localNotification.alertAction = @"Show me the item";
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;
[localNotification setRepeatInterval:NSCalendarUnitDay];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
,這是我的應用程序委託didReceiveLocalNotification編碼,
- (void)application:(UIApplication *)application didReceiveLocalNotification:(nonnull UILocalNotification *)notification {
UIApplicationState state = [application applicationState];
if (state == UIApplicationStateActive) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Reminder"
message:notification.alertBody
delegate:self cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
// Request to reload table view data
[[NSNotificationCenter defaultCenter] postNotificationName:@"reloadData" object:self];
// Set icon badge number to zero
application.applicationIconBadgeNumber = 0;
}
如何檢查接收通知日期和時間是否等於結束日期和時間字符串。那麼只有它可能的權利?,請你解釋一下。 – Jaikannan