Ich entwickle eine iOS App, die eine lokale Benachrichtigung als Warnung auf dem Bildschirm in der App macht. Ich möchte, dass es die Benachrichtigung an den Hauptbereich Benachrichtigungen sendet und stattdessen nichts auf dem Bildschirm anzeigt. Wie kann ich das machen?Senden Sie UILocalNotification an den Hauptbereich Notifications anstelle von Alert
Im Moment sagt der Infobereich nur "No Notifications".
Hier ist mein Code:
AppDelegate
- (void)application:(UIApplication *)application didReceiveLocalNotification:(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];
}
// Set icon badge number to zero
application.applicationIconBadgeNumber = 0;
}
Viewcontroller
self.itemText.text = @"Notification";
NSDate *pickerDate = [[NSDate alloc] initWithTimeIntervalSinceNow:5];
NSLog(@"Picked date is %@", pickerDate);
NSDate *todaysDate;
todaysDate = [NSDate date];
NSLog(@"Todays date is %@", todaysDate);
// Schedule the notification
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = pickerDate;
// TO DO : Assign proper text to self.itemText.text based on real data
localNotification.alertBody = self.itemText.text;
localNotification.alertAction = @"Another";
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
Sie drücken also grundsätzlich eine 'UILocalNotification'. Wenn Sie die Benachrichtigung in der App erhalten, müssen Sie eine Warnung in der App anzeigen. Ist das richtig? – KrishnaCA