마케팅 정보를 업데이트를 앱을 실행할 때 한번만 실행하도록 수정
로그인/회원가입 시 마케팅 정보를 업데이트 하도록 수정
This commit is contained in:
parent
e8f909035a
commit
236cf4db1e
|
@ -12,6 +12,7 @@ class AppState: ObservableObject {
|
||||||
|
|
||||||
private var appStepBackStack = [AppStep]()
|
private var appStepBackStack = [AppStep]()
|
||||||
|
|
||||||
|
@Published var alreadyUpdatedMarketingInfo = false
|
||||||
@Published private(set) var appStep: AppStep = .splash
|
@Published private(set) var appStep: AppStep = .splash
|
||||||
|
|
||||||
@Published var isShowPlayer = false {
|
@Published var isShowPlayer = false {
|
||||||
|
|
|
@ -15,7 +15,7 @@ final class AppViewModel: ObservableObject {
|
||||||
private let userRepository = UserRepository()
|
private let userRepository = UserRepository()
|
||||||
|
|
||||||
func fetchAndUpdateIdfa() {
|
func fetchAndUpdateIdfa() {
|
||||||
DEBUG_LOG("fetchAndUpdateIdfa")
|
AppState.shared.alreadyUpdatedMarketingInfo = true
|
||||||
ATTrackingManager.requestTrackingAuthorization { [unowned self] status in
|
ATTrackingManager.requestTrackingAuthorization { [unowned self] status in
|
||||||
if status == .authorized {
|
if status == .authorized {
|
||||||
if !UserDefaults.string(forKey: UserDefaultsKey.token).trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
if !UserDefaults.string(forKey: UserDefaultsKey.token).trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||||
|
|
|
@ -25,11 +25,13 @@ struct SodaLiveApp: App {
|
||||||
}
|
}
|
||||||
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification)) { _ in
|
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification)) { _ in
|
||||||
UIApplication.shared.applicationIconBadgeNumber = 0
|
UIApplication.shared.applicationIconBadgeNumber = 0
|
||||||
|
|
||||||
AppsFlyerLib.shared().start()
|
AppsFlyerLib.shared().start()
|
||||||
|
|
||||||
|
if !AppState.shared.alreadyUpdatedMarketingInfo {
|
||||||
viewModel.fetchAndUpdateIdfa()
|
viewModel.fetchAndUpdateIdfa()
|
||||||
viewModel.getMemberInfo()
|
viewModel.getMemberInfo()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
.onOpenURL { url in
|
.onOpenURL { url in
|
||||||
DEBUG_LOG("I have received a URL through a custom scheme! \(url.absoluteString)")
|
DEBUG_LOG("I have received a URL through a custom scheme! \(url.absoluteString)")
|
||||||
ApplicationDelegate.shared.application(UIApplication.shared, open: url, options: [:])
|
ApplicationDelegate.shared.application(UIApplication.shared, open: url, options: [:])
|
||||||
|
|
|
@ -10,6 +10,7 @@ import Moya
|
||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
final class LoginViewModel: ObservableObject {
|
final class LoginViewModel: ObservableObject {
|
||||||
|
private let appViewModel = AppViewModel()
|
||||||
private let repository = UserRepository()
|
private let repository = UserRepository()
|
||||||
private var subscription = Set<AnyCancellable>()
|
private var subscription = Set<AnyCancellable>()
|
||||||
|
|
||||||
|
@ -55,6 +56,7 @@ final class LoginViewModel: ObservableObject {
|
||||||
UserDefaults.set(data.userId, forKey: .userId)
|
UserDefaults.set(data.userId, forKey: .userId)
|
||||||
UserDefaults.set(data.email, forKey: .email)
|
UserDefaults.set(data.email, forKey: .email)
|
||||||
UserDefaults.set(data.token, forKey: .token)
|
UserDefaults.set(data.token, forKey: .token)
|
||||||
|
self.appViewModel.fetchAndUpdateIdfa()
|
||||||
AppState.shared.isChangeAdultContentVisible = true
|
AppState.shared.isChangeAdultContentVisible = true
|
||||||
AppState.shared.setAppStep(step: .splash)
|
AppState.shared.setAppStep(step: .splash)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import Combine
|
||||||
import Moya
|
import Moya
|
||||||
|
|
||||||
final class SignUpViewModel: ObservableObject {
|
final class SignUpViewModel: ObservableObject {
|
||||||
|
private let appViewModel = AppViewModel()
|
||||||
private let repository = UserRepository()
|
private let repository = UserRepository()
|
||||||
private var subscription = Set<AnyCancellable>()
|
private var subscription = Set<AnyCancellable>()
|
||||||
|
|
||||||
|
@ -58,6 +59,7 @@ final class SignUpViewModel: ObservableObject {
|
||||||
UserDefaults.set(data.userId, forKey: .userId)
|
UserDefaults.set(data.userId, forKey: .userId)
|
||||||
UserDefaults.set(data.email, forKey: .email)
|
UserDefaults.set(data.email, forKey: .email)
|
||||||
UserDefaults.set(data.token, forKey: .token)
|
UserDefaults.set(data.token, forKey: .token)
|
||||||
|
self.appViewModel.fetchAndUpdateIdfa()
|
||||||
AppState.shared.isChangeAdultContentVisible = true
|
AppState.shared.isChangeAdultContentVisible = true
|
||||||
AppState.shared.setAppStep(step: .splash)
|
AppState.shared.setAppStep(step: .splash)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue