Can we lock the app while app goes to sleep mode in IPhone?

后端 未结 4 1914
耶瑟儿~
耶瑟儿~ 2021-02-11 11:18

I am working an app where lock option is included.My app starts with passcode screen.If I enter correct code then it navigates to next screen.If I dont use the app for long time

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-11 11:45

    You can detect when your app goes to the background using the UIApplicationDidEnterBackgroundNotification. When it does, record the date and time. When the user opens the app back up, you will receive UIApplicationWillEnterForegroundNotification. When you receive that, compare the recorded date and time with the current date and time. If that's too old, display the passcode screen.

提交回复
热议问题