Hier ist meine lokale Benachrichtigungscode, ich bekomme eine Benachrichtigung täglich mit [localNotification setRepeatInterval:NSCalendarUnitDay];
jetzt möchte ich die Benachrichtigungen stoppen oder abbrechen nach dem Datum und Uhrzeit abläuft mit Enddatum und Uhrzeit. und wo soll ich das umsetzen, bitte erkläre es. Vorraussetzung danke.Set Reminder mit lokaler Benachrichtigung in iOS Ziel 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];
und dies ist mein AppDelegate didReceiveLocalNotification Codierungen,
- (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;
}
Wie überprüfe ich, ob das Benachrichtigungsdatum und die Zeit dem Enddatum und der Uhrzeit entsprechen. dann nur sein mögliches recht ?, kannst du bitte erklären. – Jaikannan