I would like the notification to stay.
I have inter alia following code, it works well but the notification disappears after 5 seconds (both when app is running or terminated):
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions:
[UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
let nc = UNUserNotificationCenter.current()
nc.delegate = self
return true
}
public func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let request = notification.request
let identifier = request.identifier
let userInfo = notification.request.content.userInfo
completionHandler([.banner, .list, .badge, .sound])
}
I only cited a part of the code here above, which is in the main App swift file (The creation of the notification is, as usual, in another file).
I cited this part, because I presume, but do not know, that it has something to do with launchOptions or completionHandler.
Hope someone has an idea.