53 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
//
 | 
						|
//  SodaLiveApp.swift
 | 
						|
//  SodaLive
 | 
						|
//
 | 
						|
//  Created by klaus on 2023/08/09.
 | 
						|
//
 | 
						|
 | 
						|
import SwiftUI
 | 
						|
 | 
						|
import FBSDKCoreKit
 | 
						|
import AppsFlyerLib
 | 
						|
 | 
						|
@main
 | 
						|
struct SodaLiveApp: App {
 | 
						|
    
 | 
						|
    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
 | 
						|
    
 | 
						|
    @ObservedObject var viewModel = AppViewModel()
 | 
						|
    
 | 
						|
    @StateObject var canPgPaymentViewModel = CanPgPaymentViewModel()
 | 
						|
    
 | 
						|
    var body: some Scene {
 | 
						|
        WindowGroup {
 | 
						|
            ContentView(canPgPaymentViewModel: canPgPaymentViewModel)
 | 
						|
                .onReceive(NotificationCenter.default.publisher(for: UIApplication.didEnterBackgroundNotification)) { _ in
 | 
						|
                    CreatorCommunityMediaPlayerManager.shared.pauseContent()
 | 
						|
                }
 | 
						|
                .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)
 | 
						|
                    }
 | 
						|
                }
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |