-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ABW-3437] Implement deferred deep link solution (#1176)
- Loading branch information
1 parent
5a676d2
commit bb43174
Showing
6 changed files
with
54 additions
and
3 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
RadixWallet/Clients/AppsFlyerClient/AppsFlyerClient+Interface.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
RadixWallet/Clients/AppsFlyerClient/AppsFlyerClient+Live.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,56 @@ | ||
import AppsFlyerLib | ||
|
||
// MARK: - AppsFlyerClient + DependencyKey | ||
extension AppsFlyerClient: DependencyKey { | ||
static var liveValue: AppsFlyerClient { | ||
@Dependency(\.sensitiveInfoClient) var sensitiveInfoClient | ||
let state = State() | ||
|
||
actor State { | ||
let delegate = Delegate() | ||
} | ||
|
||
return .init( | ||
start: { | ||
guard | ||
let devKey = sensitiveInfoClient.read(.appsFlyerDevKey), | ||
let appId = sensitiveInfoClient.read(.appsFlyerAppId) | ||
else { | ||
loggerGlobal.info("Skipping AppsFlyer start as keys are missing") | ||
return | ||
} | ||
AppsFlyerLib.shared().appsFlyerDevKey = devKey | ||
AppsFlyerLib.shared().appleAppID = appId | ||
|
||
AppsFlyerLib.shared().deepLinkDelegate = state.delegate | ||
|
||
#if DEBUG | ||
AppsFlyerLib.shared().isDebug = true | ||
#endif | ||
|
||
AppsFlyerLib.shared().start() | ||
}, | ||
continue: { userActivity in | ||
AppsFlyerLib.shared().continue(userActivity) | ||
} | ||
) | ||
} | ||
|
||
private class Delegate: NSObject, DeepLinkDelegate, @unchecked Sendable { | ||
func didResolveDeepLink(_ result: DeepLinkResult) { | ||
if let deepLink = result.deepLink { | ||
loggerGlobal.info("did resolve deep link. Is deferred: \(deepLink.isDeferred). Click events: \(deepLink.clickEvent)") | ||
if deepLink.isDeferred { | ||
let message = if let deepLinkValue = deepLink.clickEvent["deep_link_value"] as? String { | ||
"Resolved deferred DL with value \(deepLinkValue)" | ||
} else { | ||
"Resolved deferred DL without value" | ||
} | ||
AppsFlyerLib.shared().logEvent(message, withValues: deepLink.clickEvent) | ||
} | ||
} else if let error = result.error { | ||
loggerGlobal.info("failed to resolve deep link. Status: \(result.status), Error: \(error.localizedDescription)") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters