Ich möchte eine Warnung anzeigen, wenn die lokale Benachrichtigung ausgelöst wird, aber dafür muss ich um Erlaubnis fragen, wie es mir sagt, wenn ich die App auf meinem iPhone starte :Benutzer um Erlaubnis bitten, beim Auslösen lokale Benachrichtigung zu zeigen
Der Versuch, eine lokale Meldung {Feuer date = freitag 13. Juni 2014 12 h 10 min 27 s Mitteleuropäische Sommerzeit, Zeitzone = (null) zu planen, wiederholen Intervall = 0, Wiederholungszahl = UILocalNotificationInfiniteRepeatCount, nächste Feuerdatum = Freitag, 13. Juni 2014 12 h 10 min 27 s Mitteleuropäische Sommerzeit, Benutzerinfo = (null)} mit einer Warnung, aber keine Berechtigung vom Benutzer zum Anzeigen von Warnungen erhalten
Wie kann ich das tun? Heres der Code, wie es jetzt ist:
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.fireDate = [[NSDate date] dateByAddingTimeInterval:timeUntilNotification];
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.alertBody = @"ZEIT!";
localNotif.alertAction = @"Show me the Timer!";
localNotif.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] +1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
iOS 8 erfordert eine Genehmigung. Siehe http://StackOverflow.com/a/24161903 –
Überprüfen Sie diese: http://StackOverflow.com/Questions/24100313/ask-for-user-permission-to-receive-uilocalnotifications-in-ios-8 –