Skip to content

Commit

Permalink
Bug 1388408 - Save deferred deep link to be launched from IntroViewCo…
Browse files Browse the repository at this point in the history
…ntroller (#3020)
  • Loading branch information
vbudhram authored and st3fan committed Aug 23, 2017
1 parent 2764590 commit 14196f4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Client/Application/AdjustIntegration.swift
Expand Up @@ -180,4 +180,14 @@ extension AdjustIntegration: AdjustDelegate {
static func setEnabled(_ enabled: Bool) {
Adjust.setEnabled(enabled)
}

/// Store the deeplink url from Adjust SDK. Per Adjust documentation, any interstitial view launched could interfere
/// with launching the deeplink. We let the interstial view decide what to do with deeplink.
/// Ref: https://github.com/adjust/ios_sdk#deferred-deep-linking-scenario

func adjustDeeplinkResponse(_ deeplink: URL!) -> Bool {
profile.prefs.setString("\(deeplink)", forKey: "AdjustDeeplinkKey")
return true
}

}
19 changes: 18 additions & 1 deletion Client/Frontend/Browser/BrowserViewController.swift
Expand Up @@ -2703,12 +2703,25 @@ extension BrowserViewController: IntroViewControllerDelegate {

return false
}

func launchFxAFromDeeplinkURL(_ url: URL) {
self.profile.prefs.removeObjectForKey("AdjustDeeplinkKey")
let query = url.getQuery()
let fxaParams: FxALaunchParams
fxaParams = FxALaunchParams(query: query)
self.presentSignInViewController(fxaParams)
}

func introViewControllerDidFinish(_ introViewController: IntroViewController) {
introViewController.dismiss(animated: true) { finished in
if self.navigationController?.viewControllers.count ?? 0 > 1 {
_ = self.navigationController?.popToRootViewController(animated: true)
}

guard let deeplink = self.profile.prefs.stringForKey("AdjustDeeplinkKey"), let url = URL(string: deeplink) else {
return
}
self.launchFxAFromDeeplinkURL(url)
}
}

Expand Down Expand Up @@ -2738,7 +2751,11 @@ extension BrowserViewController: IntroViewControllerDelegate {

func introViewControllerDidRequestToLogin(_ introViewController: IntroViewController) {
introViewController.dismiss(animated: true, completion: { () -> Void in
self.presentSignInViewController()
guard let deeplink = self.profile.prefs.stringForKey("AdjustDeeplinkKey"), let url = URL(string: deeplink) else {
self.presentSignInViewController()
return
}
self.launchFxAFromDeeplinkURL(url)
})
}
}
Expand Down

0 comments on commit 14196f4

Please sign in to comment.