pid를 심어놓은 광고를 타고 들어온 경우 항상 AppLaunch 이벤트를 실행하는 코드
This commit is contained in:
parent
236cf4db1e
commit
82dc43b40f
|
@ -6,6 +6,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
import Combine
|
||||||
|
|
||||||
import notifly_sdk
|
import notifly_sdk
|
||||||
import AppsFlyerLib
|
import AppsFlyerLib
|
||||||
|
@ -17,6 +18,9 @@ import FirebaseMessaging
|
||||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||||
|
|
||||||
private let gcmMessageIDKey = "gcm.message_id"
|
private let gcmMessageIDKey = "gcm.message_id"
|
||||||
|
private let adTrackingRepository = AdTrackingRepository()
|
||||||
|
|
||||||
|
private var subscription = Set<AnyCancellable>()
|
||||||
|
|
||||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
|
||||||
FirebaseApp.configure()
|
FirebaseApp.configure()
|
||||||
|
@ -87,6 +91,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||||
private func logUtmInFirebase() {
|
private func logUtmInFirebase() {
|
||||||
FirebaseTracking.shared.logUtm()
|
FirebaseTracking.shared.logUtm()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func adTrackingAppLaunch(pid: String) {
|
||||||
|
adTrackingRepository.adTrackingAppLaunch(pid: pid)
|
||||||
|
.sink { result in
|
||||||
|
switch result {
|
||||||
|
case .finished:
|
||||||
|
DEBUG_LOG("finish")
|
||||||
|
case .failure(let error):
|
||||||
|
ERROR_LOG(error.localizedDescription)
|
||||||
|
}
|
||||||
|
} receiveValue: { _ in
|
||||||
|
}
|
||||||
|
.store(in: &self.subscription)
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension AppDelegate: AppsFlyerLibDelegate {
|
extension AppDelegate: AppsFlyerLibDelegate {
|
||||||
|
@ -96,6 +115,7 @@ extension AppDelegate: AppsFlyerLibDelegate {
|
||||||
let pid = conversionInfo["deep_link_sub1"] as? String ?? ""
|
let pid = conversionInfo["deep_link_sub1"] as? String ?? ""
|
||||||
if !pid.isEmpty {
|
if !pid.isEmpty {
|
||||||
UserDefaults.set(pid, forKey: .marketingPid)
|
UserDefaults.set(pid, forKey: .marketingPid)
|
||||||
|
adTrackingAppLaunch(pid: pid)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let utmSource = conversionInfo["deep_link_sub2"] as? String {
|
if let utmSource = conversionInfo["deep_link_sub2"] as? String {
|
||||||
|
@ -155,6 +175,7 @@ extension AppDelegate: DeepLinkDelegate {
|
||||||
let pid = deepLinkObj.clickEvent["deep_link_sub1"] as? String ?? ""
|
let pid = deepLinkObj.clickEvent["deep_link_sub1"] as? String ?? ""
|
||||||
if !pid.isEmpty {
|
if !pid.isEmpty {
|
||||||
UserDefaults.set(pid, forKey: .marketingPid)
|
UserDefaults.set(pid, forKey: .marketingPid)
|
||||||
|
adTrackingAppLaunch(pid: pid)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let utmSource = deepLinkObj.clickEvent["deep_link_sub2"] as? String {
|
if let utmSource = deepLinkObj.clickEvent["deep_link_sub2"] as? String {
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
//
|
||||||
|
// AdTrackingApi.swift
|
||||||
|
// SodaLive
|
||||||
|
//
|
||||||
|
// Created by klaus on 3/26/25.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Moya
|
||||||
|
|
||||||
|
enum AdTrackingApi {
|
||||||
|
case appLaunch(pid: String)
|
||||||
|
}
|
||||||
|
|
||||||
|
extension AdTrackingApi: TargetType {
|
||||||
|
var baseURL: URL {
|
||||||
|
return URL(string: BASE_URL)!
|
||||||
|
}
|
||||||
|
|
||||||
|
var path: String {
|
||||||
|
switch self {
|
||||||
|
case .appLaunch:
|
||||||
|
return "/ad-tracking/app-launch"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var method: Moya.Method {
|
||||||
|
switch self {
|
||||||
|
case .appLaunch:
|
||||||
|
return .post
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var task: Moya.Task {
|
||||||
|
switch self {
|
||||||
|
case .appLaunch(let pid):
|
||||||
|
return .requestJSONEncodable(AdTrackingAppLaunchRequest(pid: pid))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var headers: [String : String]? {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
//
|
||||||
|
// AdTrackingAppLaunchRequest.swift
|
||||||
|
// SodaLive
|
||||||
|
//
|
||||||
|
// Created by klaus on 3/26/25.
|
||||||
|
//
|
||||||
|
|
||||||
|
struct AdTrackingAppLaunchRequest: Encodable {
|
||||||
|
let pid: String
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
//
|
||||||
|
// AdTrackingRepository.swift
|
||||||
|
// SodaLive
|
||||||
|
//
|
||||||
|
// Created by klaus on 3/26/25.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import CombineMoya
|
||||||
|
import Combine
|
||||||
|
import Moya
|
||||||
|
|
||||||
|
final class AdTrackingRepository {
|
||||||
|
private let api = MoyaProvider<AdTrackingApi>()
|
||||||
|
|
||||||
|
func adTrackingAppLaunch(pid: String) -> AnyPublisher<Response, MoyaError> {
|
||||||
|
return api.requestPublisher(.appLaunch(pid: pid))
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue