How to determine iPhone is being used/unlocked

☆樱花仙子☆ 提交于 2019-12-12 20:26:08

问题


I am facing one of the requirements where I need to detect if the user is using the iPhone or not. Even if my app is in background then also. So far I've found the following way outs, but none of them points to the unlocking mechanism:

  1. applicationProtectedDataWillBecomeUnavailable: This will tell if the user has locked/unlocked the device but will work only If a passcode is set.

  2. Darwin lock/unlock notifications: Not accepted on AppStore.

  3. Proximity Sensor (UIDeviceProximityStateDidChangeNotification): This will only happen if the user is calling.

  4. [[UIScreen mainScreen] brightness]: Can be queried during applicationDidEnterBackground state to check whether phone was locked or home button was pressed. If brightness is greater than 0, it indicates home button was pressed or there was a transition to some other app, when it is 0, it means locked.

  5. Using motion sensors: Given the battery drainage, a fairly incorrect approach to check what's the roll of the device or acceleration in a certain coordinate system

  6. UIDeviceOrientationDidChangeNotification: only works when app is in foreground.

  7. What's the technology behind apple's "pick up to wake" implementation: I have seen that iPhone6s brightens the screen when you pick it up. They must be using a more efficient way than accelerometer?

I don't see any other good approaches. Did I miss something?

来源:https://stackoverflow.com/questions/50115099/how-to-determine-iphone-is-being-used-unlocked

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!