简体   繁体   中英

openUrl not being called when I launch the app from Scheme Url

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.

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 }

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:

在此处输入图像描述

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM