From 23e99c443c147f95aac8a157325ba98a14f2104e Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Tue, 18 Mar 2025 23:26:32 +0900 Subject: [PATCH] =?UTF-8?q?AppsFlyer=20=EB=94=A5=EB=A7=81=ED=81=AC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EC=84=A4=EC=A0=95=20-=20onConversionDataS?= =?UTF-8?q?uccess=EC=97=90=20=EB=A0=88=EA=B1=B0=EC=8B=9C=20=EB=94=A5?= =?UTF-8?q?=EB=A7=81=ED=81=AC=20=EC=B2=98=EB=A6=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SodaLive/Sources/App/AppDelegate.swift | 49 ++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/SodaLive/Sources/App/AppDelegate.swift b/SodaLive/Sources/App/AppDelegate.swift index 21e04fb..9301537 100644 --- a/SodaLive/Sources/App/AppDelegate.swift +++ b/SodaLive/Sources/App/AppDelegate.swift @@ -92,6 +92,41 @@ class AppDelegate: UIResponder, UIApplicationDelegate { extension AppDelegate: AppsFlyerLibDelegate { func onConversionDataSuccess(_ conversionInfo: [AnyHashable : Any]) { DEBUG_LOG("AppsFlyer Conversion Data: \(conversionInfo)") + if let status = conversionInfo["af_status"] as? String, status == "Non-organic" { + let pid = conversionInfo["deep_link_sub1"] as? String ?? "" + if !pid.isEmpty { + UserDefaults.set(pid, forKey: .marketingPid) + } + + if let utmSource = conversionInfo["deep_link_sub2"] as? String { + AppState.shared.marketingUtmSource = utmSource + } + + if let utmMedium = conversionInfo["deep_link_sub3"] as? String { + AppState.shared.marketingUtmMedium = utmMedium + } + + if let utmCampaign = conversionInfo["deep_link_sub4"] as? String { + AppState.shared.marketingUtmCampaign = utmCampaign + } + + let deepLinkValue = conversionInfo["deep_link_value"] as? String ?? "" + let deepLinkValueId = Int(conversionInfo["deep_link_sub5"] as? String ?? "") ?? 0 + + if deepLinkValueId > 0 { + if deepLinkValue == "series" { + AppState.shared.pushSeriesId = deepLinkValueId + } else if deepLinkValue == "content" { + AppState.shared.pushAudioContentId = deepLinkValueId + } else if deepLinkValue == "live" { + AppState.shared.pushRoomId = deepLinkValueId + } else if deepLinkValue == "channel" { + AppState.shared.pushChannelId = deepLinkValueId + } + } + + logUtmInFirebase() + } } func onConversionDataFail(_ error: any Error) { @@ -122,9 +157,17 @@ extension AppDelegate: DeepLinkDelegate { UserDefaults.set(pid, forKey: .marketingPid) } - AppState.shared.marketingUtmSource = deepLinkObj.clickEvent["deep_link_sub2"] as? String ?? "" - AppState.shared.marketingUtmMedium = deepLinkObj.clickEvent["deep_link_sub3"] as? String ?? "" - AppState.shared.marketingUtmCampaign = deepLinkObj.clickEvent["deep_link_sub4"] as? String ?? "" + if let utmSource = deepLinkObj.clickEvent["deep_link_sub2"] as? String { + AppState.shared.marketingUtmSource = utmSource + } + + if let utmMedium = deepLinkObj.clickEvent["deep_link_sub3"] as? String { + AppState.shared.marketingUtmMedium = utmMedium + } + + if let utmCampaign = deepLinkObj.clickEvent["deep_link_sub4"] as? String { + AppState.shared.marketingUtmCampaign = utmCampaign + } let deepLinkValue = deepLinkObj.clickEvent["deep_link_value"] as? String ?? "" let deepLinkValueId = Int(deepLinkObj.clickEvent["deep_link_sub5"] as? String ?? "") ?? 0