4

This may be a newbie question.

When Application in the background and I click the scheme URL (something like "myApp://blabla") to launch the app, open url methods work fine. No problem.

But when the app doesn't in the background or killed by swiping up, and after that I click the url(myApp://blabla) the app launches but doesn't call the openUrl methods in AppDelegate.

So, I can't navigate the app correctly.

Solved: As @ctietze told, didFinishLaunchingWithOptions wasn't return true, that was the problem.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
GreatCornholio
  • 97
  • 2
  • 16
  • 1
    According to the docs, "This method is not called if your implementations return false from both the application(_:willFinishLaunchingWithOptions:) and application(_:didFinishLaunchingWithOptions:) methods."(https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623112-application) So check if that's `true`. – ctietze Jul 18 '18 at 08:05

3 Answers3

1

In this case you have to check didFinishLaunchingWithOptions delegate method

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
   if let url = launchOptions?[UIApplication.LaunchOptionsKey.url] as? URL {
      /// some
   }
 return true
}
Sharad Chauhan
  • 4,821
  • 2
  • 25
  • 50
Vyacheslav
  • 26,359
  • 19
  • 112
  • 194
0

Make sure you have added "myApp" all details under URL types in info.plist file. You need to add two keys in it. Check image below:

enter image description here

Satish Mavani
  • 4,897
  • 2
  • 20
  • 30
0

One solution is to comment out the SceneDelegate file, delete ApplicationSceneManifest in info.plist, then restart Xcode. Then the function will be called.