From 4b7d5c19d4474b3a97cb0b8ad94c8740362a6738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Buczek?= Date: Thu, 14 Mar 2024 18:51:53 +0100 Subject: [PATCH] [iOS] Add Brave Leo deep link. (#22598) Resolves https://github.com/brave/brave-browser/issues/36800 --- .../Browser/BrowserViewController/BVC+Callout.swift | 10 ++++++++++ .../Brave/Frontend/Browser/NavigationRouter.swift | 3 +++ 2 files changed, 13 insertions(+) diff --git a/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Callout.swift b/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Callout.swift index e18917027930..43ad6e465d15 100644 --- a/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Callout.swift +++ b/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Callout.swift @@ -350,4 +350,14 @@ extension BrowserViewController { } } } + + func presentBraveLeoDeepLink() { + // If the onboarding has not completed we do not show any promo screens. + // This will most likely be the case for users who have not installed the app yet. + if Preferences.Onboarding.basicOnboardingCompleted.value != OnboardingState.completed.rawValue { + return + } + + openBraveLeo() + } } diff --git a/ios/brave-ios/Sources/Brave/Frontend/Browser/NavigationRouter.swift b/ios/brave-ios/Sources/Brave/Frontend/Browser/NavigationRouter.swift index dd665a777be9..c6255c3620b7 100644 --- a/ios/brave-ios/Sources/Brave/Frontend/Browser/NavigationRouter.swift +++ b/ios/brave-ios/Sources/Brave/Frontend/Browser/NavigationRouter.swift @@ -12,6 +12,7 @@ import Shared // To open a URL use /open-url or to open a blank tab use /open-url with no params public enum DeepLink: String { case vpnCrossPlatformPromo = "vpn_promo" + case braveLeo = "brave_leo" } // The root navigation for the Router. Look at the tests to see a complete URL @@ -86,6 +87,8 @@ public enum NavigationPath: Equatable { switch link { case .vpnCrossPlatformPromo: bvc.presentVPNInAppEventCallout() + case .braveLeo: + bvc.presentBraveLeoDeepLink() } }