我一直无法在我的iOS应用程序中正常使用自定义URL。
当我在Safari中打开该网址AppDelegate
时,它会转换回我的应用,但不会调用Info.plist
方法。
这是方法和相关的// AppDelegate.swift
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
print(url)
return true
}
数据。我将其分解为一个简单的案例,因为我在Spotify API中遇到了同样的问题。
我还有其他设置吗?
// Info.plist
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>com.bdat.test</string>
<key>CFBundleURLSchemes</key>
<array>
<string>bdat</string>
</array>
</dict>
</array>
search_path
答案 0 :(得分:-1)
此问题中的应用程序是在XCode 11.x中创建的,作为测试以确定我的真正应用程序为何无法正常工作的测试。 XCode生成应用程序时,它创建了一个SceneDelegate以及Info.plist中的条目以将其激活。 Apple的文档(https://developer.apple.com/documentation/uikit/app_and_environment/scenes/specifying_the_scenes_your_app_supports_)表示您必须明确选择加入,但显然不是。即使未选中“支持多个窗口”,它仍在其生成的SceneDelegate中调用scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>)
。我不确定这是故意的还是iOS / XCode中的错误。