My iOS app launches buggy (no launch image, safe areas aren't observed, tab bar doesn't show, etc.) when it's opened from a remote notification (when the user taps a push notification to open the app from a terminated state). I don't want the push notification to have any special functionality at all, I want it as plain as possible.
This is how I have my notifications configured in the App Delegate:
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
setupUserNotifications()
return true
}
private func setupUserNotifications() {
let notifications = UNUserNotificationCenter.current()
let connectionMessages = UNNotificationCategory(identifier: "connectionMessageNotification",
actions: [],
intentIdentifiers: [],
options: UNNotificationCategoryOptions.init())
let interactionMessages = UNNotificationCategory(identifier: "interactionMessageNotification",
actions: [],
intentIdentifiers: [],
options: UNNotificationCategoryOptions.init())
notifications.delegate = self
notifications.setNotificationCategories([connectionMessages, interactionMessages])
notifications.requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in
if granted {
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
} else {
print(if: error)
}
}
}
And this is how I handle the delegate (doing nothing and just calling completion):
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
print("did tap remote notification")
completionHandler()
}
Is there a step I'm missing? Am I supposed to implement application(_:willFinishLaunchingWithOptions:)? What I don't understand is that if the user launches the app by tapping a push notification, shouldn't the app just launch normally without having to take any extra steps?