diff --git a/Sources/Brave/Frontend/Browser/BrowserViewController.swift b/Sources/Brave/Frontend/Browser/BrowserViewController.swift index 6b65b87bbf8..db856088902 100644 --- a/Sources/Brave/Frontend/Browser/BrowserViewController.swift +++ b/Sources/Brave/Frontend/Browser/BrowserViewController.swift @@ -3162,6 +3162,9 @@ extension BrowserViewController { } public func handleNavigationPath(path: NavigationPath) { + // Remove Default Browser Callout if an external url is triggered + Preferences.General.defaultBrowserCalloutDismissed.value = true + executeAfterSetup { NavigationPath.handle(nav: path, with: self) } diff --git a/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+Callout.swift b/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+Callout.swift index b5017195e91..49e2b9030c0 100644 --- a/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+Callout.swift +++ b/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+Callout.swift @@ -268,7 +268,7 @@ extension BrowserViewController { return false } - if presentedViewController != nil || !FullScreenCalloutManager.shouldShowDefaultBrowserCallout(calloutType: calloutType) { + if presentedViewController != nil || !FullScreenCalloutManager.shouldShowCallout(calloutType: calloutType) { return false } diff --git a/Sources/Brave/Frontend/Browser/New Tab Page/NewTabPageViewController.swift b/Sources/Brave/Frontend/Browser/New Tab Page/NewTabPageViewController.swift index 0bd4d127af1..cf0c17150d1 100644 --- a/Sources/Brave/Frontend/Browser/New Tab Page/NewTabPageViewController.swift +++ b/Sources/Brave/Frontend/Browser/New Tab Page/NewTabPageViewController.swift @@ -201,6 +201,10 @@ class NewTabPageViewController: UIViewController { // This is a one-off view, adding it to the NTP only if necessary. if NTPDefaultBrowserCalloutProvider.shouldShowCallout { + // Never show Default Browser Notification over an NPT SI + if let ntpBackground = background.currentBackground, case .sponsoredImage = ntpBackground { + return + } sections.insert(NTPDefaultBrowserCalloutProvider(), at: 0) } diff --git a/Sources/Brave/Frontend/Browser/New Tab Page/Sections/NTPDefaultBrowserCalloutProvider.swift b/Sources/Brave/Frontend/Browser/New Tab Page/Sections/NTPDefaultBrowserCalloutProvider.swift index 5cf8889f9e4..271431ff8af 100644 --- a/Sources/Brave/Frontend/Browser/New Tab Page/Sections/NTPDefaultBrowserCalloutProvider.swift +++ b/Sources/Brave/Frontend/Browser/New Tab Page/Sections/NTPDefaultBrowserCalloutProvider.swift @@ -16,9 +16,29 @@ class NTPDefaultBrowserCalloutProvider: NSObject, NTPObservableSectionProvider { private typealias DefaultBrowserCalloutCell = NewTabCenteredCollectionViewCell static var shouldShowCallout: Bool { - !Preferences.General.defaultBrowserCalloutDismissed.value && + let defaultBrowserDisplayCriteria = !Preferences.General.defaultBrowserCalloutDismissed.value && !Preferences.Onboarding.basicOnboardingDefaultBrowserSelected.value && AppConstants.buildChannel == .release + + guard let appRetentionLaunchDate = Preferences.DAU.appRetentionLaunchDate.value else { + return defaultBrowserDisplayCriteria + } + + // User should not see default browser first 7 days + // also after 14 days + var defaultBrowserTimeConstraintCriteria = false + + let rightNow = Date() + let first7DayPeriod = appRetentionLaunchDate.addingTimeInterval( + AppConstants.buildChannel.isPublic ? 7.days : 7.minutes) + let first14DayPeriod = appRetentionLaunchDate.addingTimeInterval( + AppConstants.buildChannel.isPublic ? 17.days : 14.minutes) + + if rightNow > first7DayPeriod, rightNow < first14DayPeriod { + defaultBrowserTimeConstraintCriteria = true + } + + return defaultBrowserDisplayCriteria && defaultBrowserTimeConstraintCriteria } func registerCells(to collectionView: UICollectionView) { diff --git a/Sources/Onboarding/ProductNotifications/FullScreenCalloutManager.swift b/Sources/Onboarding/ProductNotifications/FullScreenCalloutManager.swift index c49f64f57e7..c951c17e71a 100644 --- a/Sources/Onboarding/ProductNotifications/FullScreenCalloutManager.swift +++ b/Sources/Onboarding/ProductNotifications/FullScreenCalloutManager.swift @@ -61,7 +61,7 @@ public enum FullScreenCalloutType: CaseIterable { public struct FullScreenCalloutManager { /// It determines whether we should show show the designated callout or not and sets corresponding preferences accordingly. /// Returns true if the callout should be shown. - public static func shouldShowDefaultBrowserCallout(calloutType: FullScreenCalloutType) -> Bool { + public static func shouldShowCallout(calloutType: FullScreenCalloutType) -> Bool { guard Preferences.Onboarding.isNewRetentionUser.value == true, let appRetentionLaunchDate = Preferences.DAU.appRetentionLaunchDate.value, !calloutType.preferenceValue.value