Detect fast double power button press

こ雲淡風輕ζ 提交于 2019-12-19 11:44:36

问题


Is it possible to detect if the user pressed the power button two times fast? Apple use the way to confirm an Appstore purchase on the new iPhone X with Face-ID. Is there any API available? Want to use it in an similar case for authenticate via Face-ID.


回答1:


No. The system itself controls response to the side (sleep/wake/power) button.

iOS accepts a double-tap on side button to prompt for Face ID authentication only during an Apple-mediated financial transaction — that is, to make a purchase from iTunes / App Store, including in-app purchases, or to complete an online Apple Pay transaction. Outside such circumstances, double-tapping the side button either brings up the UI for an in-person Apple Pay transaction or (if the setting for showing Wallet on double-tap is disabled) does nothing.

Your app is welcome to prompt for Face ID / Touch ID authentication in response to any in-app or on-screen event, but not only is there no API explicitly for responding to the side button or other hardware controls, any attempt to repurpose existing API for such reasons probably wouldn’t get past App Review:

2.5.9 Apps that alter or disable the functions of standard switches, such as the Volume Up/Down and Ring/Silent switches, or other native user interface elements or behaviors will be rejected.



来源:https://stackoverflow.com/questions/47200522/detect-fast-double-power-button-press

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