Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADHOCREQ-106] Redirect to safari for braze links that aren't deep links #1845

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions Kickstarter-iOS/AppDelegateViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -331,17 +331,21 @@ public final class AppDelegateViewModel: AppDelegateViewModelType, AppDelegateVi
.skipNil()
.map(navigation(fromPushEnvelope:))

let deepLinkFromBrazeNotification = self.remoteNotificationProperty.signal.skipNil()
let urlFromBrazeNotification = self.remoteNotificationProperty.signal.skipNil()
.map(BrazePushEnvelope.decodeJSONDictionary)
.skipNil()
.map { $0.abURI }
.skipNil()
.map(URL.init(string:))
.skipNil()
.map(Navigation.deepLinkMatch)

let deepLinkFromBrazeInAppNotification = self.brazeInAppNotificationURLProperty.signal.skipNil()
.map(Navigation.deepLinkMatch)
let urlFromBraze = Signal
.merge(
urlFromBrazeNotification,
self.brazeInAppNotificationURLProperty.signal.skipNil()
)

let deepLinkFromBraze = urlFromBraze.map(Navigation.deepLinkMatch)

let continueUserActivity = self.applicationContinueUserActivityProperty.signal.skipNil()

Expand Down Expand Up @@ -379,8 +383,7 @@ public final class AppDelegateViewModel: AppDelegateViewModelType, AppDelegateVi
.merge(
deepLinkFromUrl,
deepLinkFromNotification,
deepLinkFromBrazeNotification,
deepLinkFromBrazeInAppNotification,
deepLinkFromBraze,
deepLinkFromShortcut
)
.skipNil()
Expand Down Expand Up @@ -554,8 +557,11 @@ public final class AppDelegateViewModel: AppDelegateViewModelType, AppDelegateVi
.filter { $0 == .tab(.me) }
.ignoreValues()

let resolvedRedirectUrl = deepLinkUrl
.filter { Navigation.deepLinkMatch($0) == nil }
let resolvedRedirectUrl = Signal.merge(
deepLinkUrl,
urlFromBraze
)
.filter { Navigation.deepLinkMatch($0) == nil }

self.goToMobileSafari = resolvedRedirectUrl

Expand Down
13 changes: 13 additions & 0 deletions Kickstarter-iOS/AppDelegateViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2527,6 +2527,19 @@ final class AppDelegateViewModelTests: TestCase {
}
}

func testGoToMobileSafari_BrazeInAppNotificaton() {
self.vm.inputs.applicationDidFinishLaunching(
application: UIApplication.shared,
launchOptions: [:]
)

let url = URL(string: "https://fake-url.com")!
self.vm.inputs.urlFromBrazeInAppNotification(url)

self.goToMobileSafari.assertValues([url])
self.presentViewController.assertValues([])
}

func testRemoteConfigClientConfiguredNotification_Success() {
let mockService = MockService(serverConfig: ServerConfig.staging)

Expand Down