Ich möchte die Bannerbenachrichtigung anzeigen, wenn der Benutzer die Anwendung beendet. Und wenn ich auf dieses Banner tippe, möchte ich, dass sich meine Anwendung öffnet.Lokale Bannerbenachrichtigung zum Beenden der App
func showBanner() {
UIApplication.shared.cancelAllLocalNotifications()
let notif = UILocalNotification.init()
notif.alertBody = "Your Message Here..."
localNotif.soundName = UILocalNotificationDefaultSoundName
UIApplication.shared.presentLocalNotificationNow(notif)
}
Wenn ich diesen Code setzen in applicationDidEnterBackground
es funktioniert gut; Aber wenn ich es in applicationWillTerminate
stecke, tut es das nicht.
Problemumgehung?
EDIT:
Added fireDate
wie folgt vor:
var dc = DateComponents()
dc.second = 2 // 2 seconds from current date time
notif.fireDate = Calendar.current.date(byAdding: dc, to: Date())
immer noch nicht funktioniert. Irgendeine Idee?
wo Sie diese 'showBanner' genannt haben –
@ Anbu.Karthik Es funktioniert, wenn ich es mit' applicationDidEnterBackground' setze Aber es funktioniert nicht, wenn ich es in 'applicationWillTerminate' wie in Queston erwähnt einfügen. –
siehe http://stackoverflow.com/questions/16806293/what-is-the-delegate-method-that-will-called-when-closing-an-iphone-app-by-press –