I'm trying to open my app from a web page using custom schemes. The app is opened but the following method is not called:
func application(_ app: UIApplication, open url: URL, options [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
// This is not called
}
My info.plist
looks like the following:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>MyApp</string>
</array>
<key>CFBundleURLName</key>
<string>url here</string>
</dict>
</array>
The project is created with Xcode 11.1, and I'm testing on iOS 13.
With the latest SDK, this does work fine if you are at NOT using SceneDelegate.
If you are using sceneDelegate the the following AppDelegate method is not called and therefore the login cannot be handled.
This is because, this method is (understandably) deferred to the following method in the SceneDelegate:
The solution which I can confirm as working for iOS 13 applications implementing a SceneDelegate is:
Thanks to @Matt there This is how I solve the problem.
on SceneDelegate.m
Refer this apple documentation
This method is not called if your implementations return NO from both the application:willFinishLaunchingWithOptions: and application:didFinishLaunchingWithOptions: methods. (If only one of the two methods is implemented, its return value determines whether this method is called.) If your app implements the applicationDidFinishLaunching: method instead of application:didFinishLaunchingWithOptions:, this method is called to open the specified URL after the app has been initialized. If a URL arrives while your app is suspended or running in the background, the system moves your app to the foreground prior to calling this method. There is no equivalent notification for this delegation method.
I encountered a problem, using safari shortcut to start the application, openURLContexts callback multiple times.
Implement
scene(_:openURLContexts:)
in your scene delegate.If the URL launches your app, you will get
scene(_:willConnectTo:options:)
instead and it’s in theoptions
.