大家好 - 我是这里的新手......试图让我的第一个 iOS Swift (Xcode 11.2.1 / Swift 5 / iOS 13.2) 应用程序通过 URL 打开并处理 URL 字符串。应用程序打开得很好,但函数(方法?)似乎没有被调用。这是我所拥有的:
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
print("Here I iz ... in the URL responding bit.")
print(url)
return true
}
...
Run Code Online (Sandbox Code Playgroud)
该代码位于我项目的AppDelegate.swift文件中。
这就是我在Info.plist文件中的内容。
我在设备上和模拟器中通过 Safari 启动 confirmevent://HelloWorld
正如我所说......应用程序正在打开,但我在 Xcode 调试区域中没有看到我的打印语句的任何结果。
在搜索其他帖子时,他们说我需要使用“等待可执行文件启动”将 Xcode 附加到应用程序,我已经完成并且确实附加了。 但是我注意到,当我通过“等待可执行文件启动”选项打开时,我在应用程序中散布的数十个打印语句中没有一个出现。
任何/所有帮助将不胜感激。我花了超过 …
我正在尝试实施很酷的 Firebase 电子邮件链接登录功能,但失败了。我成功设置发送电子邮件链接。但是,我无法获得打开应用程序的电子邮件链接。它只是打开预览页面,就像无法打开应用程序一样。
我已经测试了我设置的动态链接,我可以让它在设备中打开应用程序。我只是无法获得电子邮件链接来做同样的事情。
我的应用程序中的代码:
func sendFirebaseEmailLink() {
let actionCodeSettings = ActionCodeSettings.init()
// userEmail comes from a textField
let email = userEmail
actionCodeSettings.url = URL.init(string: String(format: "https://<myappname>.firebaseapp.com/?email=%@", email))
// The sign-in operation has to always be completed in the app.
actionCodeSettings.handleCodeInApp = true
actionCodeSettings.setIOSBundleID(Bundle.main.bundleIdentifier!)
Auth.auth().sendSignInLink(toEmail: email,
actionCodeSettings: actionCodeSettings) { error in
if let error = error {
print(error.localizedDescription)
return
}
else {
UserDefaults.standard.set(email, forKey: "Email")
print("email sent to user")
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我说我已经成功获得动态链接以打开应用程序时,我的意思是当我在安装了该应用程序的设备上点击我创建的链接 (mylinkname.page.link/emaillogin) 时,它会打开该应用程序。正因为如此,[这个有用的 Firebase 视频][1] 关于设置动态链接,似乎我的这些细节是正确的,问题出在代码上,但我是新手,所以我不确定.
我花了几天的时间来解决这个问题,并试图解析密集的 Firebase …
scene(_ scene: UIScene, continue userActivity: NSUserActivity)在用户单击通用链接后启动应用程序时,不会调用方法。
当用户单击通用链接后,已启动的应用程序再次打开时,它工作正常。示例代码:
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let incomingURL = userActivity.webpageURL,
let components = NSURLComponents(url: incomingURL, resolvingAgainstBaseURL: true),
let path = components.path else {
return
}
let params = components.queryItems ?? [URLQueryItem]()
print("path = \(path)")
print("params = \(params)")
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration,但是当用户单击链接时它永远不会被调用:
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
if let scene = …Run Code Online (Sandbox Code Playgroud)