앱스플라이어 SDK 추가

This commit is contained in:
Yu Sung
2025-03-06 02:41:04 +09:00
parent dfac57ee23
commit d019f44a0e
7 changed files with 133 additions and 37 deletions

View File

@@ -7,6 +7,7 @@
import UIKit
import AppsFlyerLib
import FBSDKCoreKit
import FirebaseCore
import FirebaseMessaging
@@ -33,6 +34,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
AppEvents.shared.activateApp()
setupAppsFlyer()
return true
}
@@ -56,6 +59,65 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
}
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([any UIUserActivityRestoring]?) -> Void) -> Bool {
AppsFlyerLib.shared().continue(userActivity, restorationHandler: nil)
return true
}
private func setupAppsFlyer() {
if let infoDic = Bundle.main.infoDictionary, let devKey = infoDic["AppsFlyerDevKey"] as? String, let appId = infoDic["AppsFlyerAppID"] as? String {
AppsFlyerLib.shared().appsFlyerDevKey = devKey
AppsFlyerLib.shared().appleAppID = appId
} else {
AppsFlyerLib.shared().appsFlyerDevKey = "tWF2wbJ5nSkya5Ru9mGcPU"
AppsFlyerLib.shared().appleAppID = "6461721697"
}
AppsFlyerLib.shared().waitForATTUserAuthorization(timeoutInterval: 60)
AppsFlyerLib.shared().delegate = self
AppsFlyerLib.shared().deepLinkDelegate = self
}
}
extension AppDelegate: AppsFlyerLibDelegate {
func onConversionDataSuccess(_ conversionInfo: [AnyHashable : Any]) {
DEBUG_LOG("AppsFlyer Conversion Data: \(conversionInfo)")
}
func onConversionDataFail(_ error: any Error) {
DEBUG_LOG("AppsFlyer Conversion Data Failed: \(error.localizedDescription)")
}
}
extension AppDelegate: DeepLinkDelegate {
func didResolveDeepLink(_ result: DeepLinkResult) {
switch result.status {
case .notFound:
DEBUG_LOG("[AFSDK] Deep link not found")
return
case .failure:
DEBUG_LOG("Error \(result.error!)")
return
case .found:
DEBUG_LOG("[AFSDK] Deep link found")
}
guard let deepLinkObj:DeepLink = result.deepLink else {
DEBUG_LOG("[AFSDK] Could not extract deep link object")
return
}
if(deepLinkObj.isDeferred == true) {
DEBUG_LOG("[AFSDK] This is a deferred deep link")
}
else {
DEBUG_LOG("[AFSDK] This is a direct deep link")
}
DEBUG_LOG("deepLinkValue: \(deepLinkObj.deeplinkValue ?? "")")
}
}
extension AppDelegate: MessagingDelegate {

View File

@@ -9,6 +9,7 @@ import SwiftUI
import AppTrackingTransparency
import FBSDKCoreKit
import AppsFlyerLib
@main
struct SodaLiveApp: App {
@@ -24,11 +25,13 @@ struct SodaLiveApp: App {
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification)) { _ in
UIApplication.shared.applicationIconBadgeNumber = 0
AppsFlyerLib.shared().start()
ATTrackingManager.requestTrackingAuthorization { _ in }
}
.onOpenURL { url in
DEBUG_LOG("I have received a URL through a custom scheme! \(url.absoluteString)")
ApplicationDelegate.shared.application(UIApplication.shared, open: url, options: [:])
AppsFlyerLib.shared().handleOpen(url)
}
}
}