Files
sodalive-ios/SodaLive/Sources/App/SodaLiveApp.swift
Yu Sung 0285f62ecb 언어 설정 화면 추가 및 언어 헤더 적용
설정에서 시스템/한국어/영어/일본어 선택을 지원한다.

선택 시 Accept-Language 헤더와 UI locale을 즉시 반영한다.

언어 변경 후 스플래시를 거쳐 메인으로 소프트 재시작한다.
2025-12-16 22:56:37 +09:00

84 lines
3.4 KiB
Swift

//
// SodaLiveApp.swift
// SodaLive
//
// Created by klaus on 2023/08/09.
//
import SwiftUI
import Kingfisher
import FBSDKCoreKit
import AppsFlyerLib
@main
struct SodaLiveApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@ObservedObject var viewModel = AppViewModel()
@StateObject var canPgPaymentViewModel = CanPgPaymentViewModel()
@StateObject private var languageEnvironment = LanguageContainer.environment
init() {
configureImageCache()
// ,
LanguageHeaderProvider.initialize()
}
private func configureImageCache() {
// Kingfisher
let cache = ImageCache.default
// (). 1 MB 80~150MB
cache.memoryStorage.config.totalCostLimit = 120 * 1024 * 1024
// ()
cache.memoryStorage.config.countLimit = 200
// ()
cache.memoryStorage.config.expiration = .seconds(300)
// ()
cache.diskStorage.config.sizeLimit = 500 * 1024 * 1024
}
var body: some Scene {
WindowGroup {
ContentView(canPgPaymentViewModel: canPgPaymentViewModel)
.environment(\.locale, languageEnvironment.locale)
.task {
await LanguageContainer.service.bootstrap()
}
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didEnterBackgroundNotification)) { _ in
CreatorCommunityMediaPlayerManager.shared.pauseContent()
//
ImageCache.default.cleanExpiredMemoryCache()
}
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didReceiveMemoryWarningNotification)) { _ in
//
ImageCache.default.clearMemoryCache()
}
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification)) { _ in
UIApplication.shared.applicationIconBadgeNumber = 0
AppsFlyerLib.shared().start()
if !AppState.shared.alreadyUpdatedMarketingInfo {
viewModel.fetchAndUpdateIdfa()
viewModel.getMemberInfo()
}
}
.onOpenURL { url in
DEBUG_LOG("I have received a URL through a custom scheme! \(url.absoluteString)")
if let comps = URLComponents(url: url, resolvingAgainstBaseURL: false),
url.scheme?.lowercased() == APPSCHEME.lowercased(),
comps.host?.lowercased() == "payverse",
comps.path.lowercased() == "/result" {
canPgPaymentViewModel.handleVerifyOpenURL(url)
} else {
ApplicationDelegate.shared.application(UIApplication.shared, open: url, options: [:])
AppsFlyerLib.shared().handleOpen(url)
}
}
}
}
}