앱스플라이어 딥링크 설정
- 앱스플라이어 Onelink를 타고 들어온 경우 pid와 utm설정
This commit is contained in:
50
SodaLive/Sources/App/AppViewModel.swift
Normal file
50
SodaLive/Sources/App/AppViewModel.swift
Normal file
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// AppViewModel.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 3/6/25.
|
||||
//
|
||||
|
||||
import Combine
|
||||
import AdSupport
|
||||
import AppTrackingTransparency
|
||||
|
||||
final class AppViewModel: ObservableObject {
|
||||
private var subscription = Set<AnyCancellable>()
|
||||
|
||||
private let userRepository = UserRepository()
|
||||
|
||||
func fetchAndUpdateIdfa() {
|
||||
DEBUG_LOG("fetchAndUpdateIdfa")
|
||||
ATTrackingManager.requestTrackingAuthorization { [unowned self] status in
|
||||
if status == .authorized {
|
||||
let idfa = ASIdentifierManager.shared().advertisingIdentifier.uuidString
|
||||
let pid = UserDefaults.string(forKey: .marketingPid)
|
||||
self.userRepository.updateMarketingInfo(request: MarketingInfoUpdateRequest(adid: idfa, 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)
|
||||
} else {
|
||||
let pid = UserDefaults.string(forKey: .marketingPid)
|
||||
self.userRepository.updateMarketingInfo(request: MarketingInfoUpdateRequest(adid: "", 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user