Files
sodalive-ios/SodaLive/Sources/App/SodaLiveApp.swift
Yu Sung 42e375ec4b LINE 로그인 지원 추가
LINE 로그인 요청과 토큰 처리 흐름을 추가함
2026-01-28 19:05:42 +09:00

96 lines
3.9 KiB
Swift

//
// SodaLiveApp.swift
// SodaLive
//
// Created by klaus on 2023/08/09.
//
import SwiftUI
import Kingfisher
import FBSDKCoreKit
import AppsFlyerLib
import GoogleSignIn
import KakaoSDKCommon
import KakaoSDKAuth
import LineSDK
@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()
KakaoSDK.initSDK(appKey: KAKAO_APP_KEY)
}
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 KakaoSDKAuth.AuthApi.isKakaoTalkLoginUrl(url) {
_ = AuthController.handleOpenUrl(url: url)
return
}
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 {
_ = LoginManager.shared.application(UIApplication.shared, open: url, options: [:])
ApplicationDelegate.shared.application(UIApplication.shared, open: url, options: [:])
AppsFlyerLib.shared().handleOpen(url)
GIDSignIn.sharedInstance.handle(url)
}
}
}
}
}