iOS/Swift:如何通过在控制台Firebase上配置一个链接来获得来自App Store的安装的动态深链接?
当不安装应用程序并打开Dynamic链接时,App Store会很好地打开,但是一旦安装,如果我单击“打开”,它将打开应用程序,它将显示一条消息“导航器中的链接粘贴” ,但是动态链接仅在没有参数的情况下启动
func应用程序(_应用程序:UIAPPLICATION,继续用户行动: nsuseractivity,RestorationHandler:@escaping ([uiuseractivityRestoring]?) - > void) - > bool {
这是函数:
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
let handled = DynamicLinks.dynamicLinks()
.handleUniversalLink(userActivity.webpageURL!) { dynamiclink, error in
// ...
print(dynamiclink!)
let urlStr: String = (dynamiclink?.url?.absoluteString.lowercased())!
// UserDefaults.standard.set(urlStr, forKey: "url")
if (urlStr.contains("test?code=azerty")) {
UserDefaults.standard.set(urlStr, forKey: "url")
let str: String = UserDefaults.standard.value(forKey: "url") as! String
if (str.contains("test?code=azerty"))
{
let alert = UIAlertController(title: "test", message: str, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}}))
let navigationController = application.windows[0].rootViewController as! UINavigationController
let activeViewCont = navigationController.visibleViewController
activeViewCont?.view.isUserInteractionEnabled = false
//activeViewCont!.present(alertController, animated: true, completion: nil)
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0, execute: {
activeViewCont!.present(alert, animated: true, completion: nil)
})
}
}
}
return handled
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
print(url)
print("handleOpenURL")
//let urlStr: String = url.absoluteString.replacingOccurrences(of: "colas://", with: "")
let urlStr: String = url.absoluteString.lowercased()
// UserDefaults.standard.set(urlStr, forKey: "url")
if (urlStr.contains("test?code=azerty")) {
UserDefaults.standard.set(urlStr, forKey: "url")
let str: String = UserDefaults.standard.value(forKey: "url") as! String
if (str.contains("test?code=azerty"))
{
let alert = UIAlertController(title: "test", message: str, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}}))
let navigationController = app.windows[0].rootViewController as! UINavigationController
let activeViewCont = navigationController.visibleViewController
activeViewCont?.view.isUserInteractionEnabled = false
//activeViewCont!.present(alertController, animated: true, completion: nil)
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0, execute: {
activeViewCont!.present(alert, animated: true, completion: nil)
})
}
}
return true
}
info plist:
<key>FirebaseDynamicLinksCustomDomains</key>
<array>
<string>https://myapp.page.link</string>
</array>
firebase选项:
使用Dynamic链接在App Store安装应用程序之后,我该如何触发函数包含参数?
信息:
xxxx.xxxxxxxxx.myapp://google/link/?deep_link_id=https://myapp.page.link/&match_type=unique&utm_medium=dynamic_link&request_ip_version=IP_V4&utm_source=firebase&match_message=Link is uniquely matched for this device.
When the app is not installed, and the user open the dynamic link, the app store is well opened, but once installed, if I click on "open", it open the apps, it says a message "link paste from the navigator", but the dynamic link is only launched without the parameters
func application(_ application: UIApplication, continue userActivity:
NSUserActivity, restorationHandler: @escaping
([UIUserActivityRestoring]?) -> Void) -> Bool {
Here is the function:
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
let handled = DynamicLinks.dynamicLinks()
.handleUniversalLink(userActivity.webpageURL!) { dynamiclink, error in
// ...
print(dynamiclink!)
let urlStr: String = (dynamiclink?.url?.absoluteString.lowercased())!
// UserDefaults.standard.set(urlStr, forKey: "url")
if (urlStr.contains("test?code=azerty")) {
UserDefaults.standard.set(urlStr, forKey: "url")
let str: String = UserDefaults.standard.value(forKey: "url") as! String
if (str.contains("test?code=azerty"))
{
let alert = UIAlertController(title: "test", message: str, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}}))
let navigationController = application.windows[0].rootViewController as! UINavigationController
let activeViewCont = navigationController.visibleViewController
activeViewCont?.view.isUserInteractionEnabled = false
//activeViewCont!.present(alertController, animated: true, completion: nil)
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0, execute: {
activeViewCont!.present(alert, animated: true, completion: nil)
})
}
}
}
return handled
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
print(url)
print("handleOpenURL")
//let urlStr: String = url.absoluteString.replacingOccurrences(of: "colas://", with: "")
let urlStr: String = url.absoluteString.lowercased()
// UserDefaults.standard.set(urlStr, forKey: "url")
if (urlStr.contains("test?code=azerty")) {
UserDefaults.standard.set(urlStr, forKey: "url")
let str: String = UserDefaults.standard.value(forKey: "url") as! String
if (str.contains("test?code=azerty"))
{
let alert = UIAlertController(title: "test", message: str, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}}))
let navigationController = app.windows[0].rootViewController as! UINavigationController
let activeViewCont = navigationController.visibleViewController
activeViewCont?.view.isUserInteractionEnabled = false
//activeViewCont!.present(alertController, animated: true, completion: nil)
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0, execute: {
activeViewCont!.present(alert, animated: true, completion: nil)
})
}
}
return true
}
Info plist:
<key>FirebaseDynamicLinksCustomDomains</key>
<array>
<string>https://myapp.page.link</string>
</array>
FireBase option:
How can I get the function fired, just after install the application from the app store, with the dynamic link containing the parameters?
Message:
xxxx.xxxxxxxxx.myapp://google/link/?deep_link_id=https://myapp.page.link/&match_type=unique&utm_medium=dynamic_link&request_ip_version=IP_V4&utm_source=firebase&match_message=Link is uniquely matched for this device.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
两个问题是:
1/动态&nbsp; url的良好写作:&nbsp;
这是创建Info.plist中XCode中的url
2/参数的好方法很重要:&nbsp;
the two problems were :
1/ the good writing of the dynamical url :
This is the good way to create the url
2/ The parameter in info.plist in Xcode is important :