투케이2K

207. (ios/swift) UIApplication isIdleTimerDisabled 사용해 애플리케이션 실행 동안 화면 잠김 및 꺼짐 방지 실시 본문

IOS

207. (ios/swift) UIApplication isIdleTimerDisabled 사용해 애플리케이션 실행 동안 화면 잠김 및 꺼짐 방지 실시

투케이2K 2022. 9. 22. 11:52
반응형

[개발 환경 설정]

개발 툴 : XCODE

개발 언어 : SWIFT

 

[소스 코드]

    // MARK: - [앱 프로세스 완료 및 앱 실행 실시]
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        print("")
        print("====================================")
        print("[AppDelegate >> didFinishLaunchingWithOptions]")
        print("-------------------------------")
        print("설 명 :: 앱 프로세스 완료 및 앱 실행 실시")
        print("====================================")
        print("")
        
        
        // -----------------------------------------
        // [애플리케이션 화면 잠김 및 꺼짐 상태 방지 / true = 꺼짐 방지]
        UIApplication.shared.isIdleTimerDisabled = true
        // -----------------------------------------
        
        
        // -----------------------------------------
        // [푸시 알림 뱃지 카운트 초기화]
        UIApplication.shared.applicationIconBadgeNumber = 0
        // -----------------------------------------
        
        
        // -----------------------------------------
        // [LaunchScreen 로딩화면 지연 실시 - 3초]
        // Thread.sleep(forTimeInterval: 3.0)
        // -----------------------------------------
        
        
        // -----------------------------------------
        // [SEARCH FAST] : [빌드 타입 확인 실시]
        #if DEBUG
            print("")
            print("====================================")
            print("[AppDelegate >> didFinishLaunchingWithOptions]")
            print("-------------------------------")
            print("설 명 :: ", "빌드 타입 확인 실시")
            print("-------------------------------")
            print("빌드 타입 :: ", "DEBUG 실행")
            print("====================================")
            print("")
        #else
            print("")
            print("====================================")
            print("[AppDelegate >> didFinishLaunchingWithOptions]")
            print("-------------------------------")
            print("설 명 :: ", "빌드 타입 확인 실시")
            print("-------------------------------")
            print("빌드 타입 :: ", "RELEASE 실행")
            print("====================================")
            print("")
        #endif
        // -----------------------------------------

        
        // -----------------------------------------
        return true
        // -----------------------------------------
    }

반응형
Comments