pid 업데이트 로직

- 로그인 된 사람만 실행되도록 수정
This commit is contained in:
Yu Sung 2025-03-10 17:12:56 +09:00
parent 72d37b6bb6
commit 96dbe50a09
1 changed files with 27 additions and 23 deletions

View File

@ -18,32 +18,36 @@ final class AppViewModel: ObservableObject {
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)
if !UserDefaults.string(forKey: UserDefaultsKey.token).trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
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
}
} receiveValue: { _ in
}
.store(in: &self.subscription)
.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)
if !UserDefaults.string(forKey: UserDefaultsKey.token).trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
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
}
} receiveValue: { _ in
}
.store(in: &self.subscription)
.store(in: &self.subscription)
}
}
}
}