From 96dbe50a09fb2cb4b8b5d1efdfb7360bfcedafe3 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Mon, 10 Mar 2025 17:12:56 +0900 Subject: [PATCH] =?UTF-8?q?pid=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20-=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EB=90=9C=20=EC=82=AC=EB=9E=8C=EB=A7=8C=20=EC=8B=A4=ED=96=89?= =?UTF-8?q?=EB=90=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SodaLive/Sources/App/AppViewModel.swift | 50 +++++++++++++------------ 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/SodaLive/Sources/App/AppViewModel.swift b/SodaLive/Sources/App/AppViewModel.swift index c542ff7..ee94163 100644 --- a/SodaLive/Sources/App/AppViewModel.swift +++ b/SodaLive/Sources/App/AppViewModel.swift @@ -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) + } } } }