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

后端 未结 4 1807
孤独总比滥情好
孤独总比滥情好 2021-02-11 10:52

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:31

    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.

提交回复
热议问题