Working on a new app built in xcode 11.2 for iOS 13.x. The app is a single-view storyboard app, but like all apps created under 11, it defaults to using the scene delegate for lifecycle events.
The app exports a custom file type and registers as owner of that type. When the app is in the background it is automatically brought to the foreground when a file of the custom type is accessed in the Files app, delivered to the device over AirDrop, opene from Mail, etc. This happens by calling the scene delegate's openURLContainers method:
func scene(_ scene: UIScene, openURLContexts URLContexts: Set) {
// handle URLs here...
// This works when the app is already in memory
// but is never called if the app is launched from cold/dark
}
However, when the app is not resident in memory (i.e. following a restart or after the app has been killed) the expected behavior does not occur. The app is launched, but the opeURLContexts method is never called.
I thought that perhaps in this situation the legacy process in appDelegate would be called (i.e. a LauchOptionsKey of type .url in the launchOptions dictionary). That does not appear to be the case either. The launchOptions dictionary is always nil.
Is this a bug, or is there some other way to catch the URL for the file in this new scene-based world?