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") DEBUG_LOG("fetchAndUpdateIdfa")
ATTrackingManager.requestTrackingAuthorization { [unowned self] status in ATTrackingManager.requestTrackingAuthorization { [unowned self] status in
if status == .authorized { if status == .authorized {
let idfa = ASIdentifierManager.shared().advertisingIdentifier.uuidString if !UserDefaults.string(forKey: UserDefaultsKey.token).trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
let pid = UserDefaults.string(forKey: .marketingPid) let idfa = ASIdentifierManager.shared().advertisingIdentifier.uuidString
self.userRepository.updateMarketingInfo(request: MarketingInfoUpdateRequest(adid: idfa, pid: pid)) let pid = UserDefaults.string(forKey: .marketingPid)
.sink { result in self.userRepository.updateMarketingInfo(request: MarketingInfoUpdateRequest(adid: idfa, pid: pid))
switch result { .sink { result in
case .finished: switch result {
DEBUG_LOG("finish") case .finished:
case .failure(let error): DEBUG_LOG("finish")
ERROR_LOG(error.localizedDescription) case .failure(let error):
ERROR_LOG(error.localizedDescription)
}
} receiveValue: { _ in
} }
} receiveValue: { _ in .store(in: &self.subscription)
} }
.store(in: &self.subscription)
} else { } else {
let pid = UserDefaults.string(forKey: .marketingPid) if !UserDefaults.string(forKey: UserDefaultsKey.token).trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
self.userRepository.updateMarketingInfo(request: MarketingInfoUpdateRequest(adid: "", pid: pid)) let pid = UserDefaults.string(forKey: .marketingPid)
.sink { result in self.userRepository.updateMarketingInfo(request: MarketingInfoUpdateRequest(adid: "", pid: pid))
switch result { .sink { result in
case .finished: switch result {
DEBUG_LOG("finish") case .finished:
case .failure(let error): DEBUG_LOG("finish")
ERROR_LOG(error.localizedDescription) case .failure(let error):
ERROR_LOG(error.localizedDescription)
}
} receiveValue: { _ in
} }
} receiveValue: { _ in .store(in: &self.subscription)
} }
.store(in: &self.subscription)
} }
} }
} }