Reputation: 2601
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.
Upvotes: 1
Views: 1900
Reputation: 1194
the two problems were :
1/ the good writing of the dynamical url :
https://yourapp.page.link/?link=https://yourapp.com/test=12345&isi=14602xxxxx&ibi=com.xxxx.yourapp
This is the good way to create the url
2/ The parameter in info.plist in Xcode is important :
<key>FirebaseDynamicLinksCustomDomains</key>
<array>
<string>https://yourapp.com/link</string>
</array>
Upvotes: 1