im实现深层链接是iOS。我已经在Project-Setting-> Info-> Url类型中配置了URL SchemeURL方案:洗车角色:查看者
[当我键入carwash://时,浏览器要求打开应用程序,但在应用程序中没有任何调用,我处理应该采取的措施。
Apple文档说您应该在AppDelegate中覆盖应用程序(打开url),但是深层链接会调用它,并且应用程序将以最后状态打开
这是我的代码,不起作用
func application(_ app: UIApplication, open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
fatalError()
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
if let url = launchOptions?[UIApplication.LaunchOptionsKey.url] as? URL {
/// some
fatalError()
}
GMSServices.provideAPIKey("")
return true
}
swift 5模拟器:iOS 13
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>carwash</string> // your identifier
<key>CFBundleURLSchemes</key>
<array>
<string>carwash</string> // schema
</array>
</dict>
</array>
return语句
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
print("Got from URL: \(url)"
return true
}
模拟器中的链接最好通过终端进行
xcrun simctl openurl booted “carwasher://deeplink”
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
if let url = URLContexts.first?.url{
print(url)
}
}