Local Notification funktioniert nicht

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Local Notification funktioniert nicht

    Hallo mal an alle!
    Ich wollte eine Art Wecker erstellen, aber die erstellte Notification erscheint nicht, wenn ich außerhalb der App bin.
    In meinem View habe ich einen DatePicker und einen Button der der "Set" heißt. Wenn ich nun ein Datum und eine Uhrzeit einstelle und "Set" drücke, sollte eigentlich ein
    AlertView kommen, wenn ich außerhalb der App bin, aber er kommt nicht.

    Eine andere Frage ist, wie ich auch eine solche Benachrichtigung sende, wenn ich innerhalb der App bin.


    Quellcode

    1. -(void) scheduleLocalNotificationWithDate: (NSDate *) fireDate
    2. {
    3. UILocalNotification *notification = [[UILocalNotification alloc] init];
    4. notification.fireDate = fireDate;
    5. notification.alertBody = @"Time Over!";
    6. [[UIApplication sharedApplication] scheduleLocalNotification:notification];
    7. }
    8. - (IBAction)setAlarmButtonPressed:(id)sender
    9. {
    10. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    11. dateFormatter.timeZone = [NSTimeZone defaultTimeZone];
    12. dateFormatter.locale = [NSLocale systemLocale];
    13. dateFormatter.timeStyle = NSDateFormatterShortStyle;
    14. dateFormatter.dateStyle = NSDateFormatterShortStyle;
    15. NSString *dateTimeString = [dateFormatter stringFromDate:datePicker.date];
    16. NSLog(@"Alarm Time %@", dateTimeString);
    17. [self scheduleLocalNotificationWithDate:datePicker.date];
    18. }
    Alles anzeigen


    Danke schon im voraus für eure Antworten!