Catching hardware buttons on iOS when my app is in

2019-08-31 06:16发布

I would like to execute some code when user presses one of home, power or volume buttons(it doesn't matter, which of these).

I would like to catch events even application is minimized to background and device is sleeping.

So primary task is processing events, when device is inside user's pocket and the user presses button, but not takes out the device.

Is that possible? If it isnt't possible for power button, may be it's possible for volume or home buttons? How can I do it?

2条回答
啃猪蹄的小仙女
2楼-- · 2019-08-31 06:44

There is idea about volume buttons, if you create player instance you can get notifications about volume change, not sure that is still work but you can try.

see answers here: program access to iPhone volume buttons

查看更多
欢心
3楼-- · 2019-08-31 06:49

Your application cannot interact with the hardware buttons on an iOS device. Your application can receive notification that it has entered the background (which may be a side-effect of the use pressing the home button, for example) but that is about all

查看更多
登录 后发表回答