Home  >  Q&A  >  body text

iOS应用退出到后台后怎样监听摇晃事件

iOS应用在前台运行时可以监听到摇一摇的动作,类似微信的摇一摇功能,目前有个需求应用退出到后台后任然能实现摇一摇,但是尝试了各种方法,都无法在应用退出前台后检测到摇一摇事件,请教各位大神如何实现该需求

PHPzPHPz2764 days ago906

reply all(4)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 13:32:31

    I started using the event monitoring of UIKit motion-event. When the application is running in the foreground, the shake action can be monitored. When the application exits the foreground, even if the background is alive (the application is active for about 10 minutes before exiting), it cannot be monitored. action.
    Using the CoreMotion framework, shaking motions can be detected while the app is running in the background.

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 13:32:31

    Personally, I think this demand cannot be met, although I don’t understand iOS development. Just imagine, if iOS provides this interface, and there are multiple applications in the background calling this interface, and you shake the screen in the foreground, which application should jump out...

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 13:32:31

    Want to know what background process capabilities the iOS platform opens to applications.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 13:32:31

    I am not working on iOS. I thought that when the app program is in the background, it can only passively receive push messages and cannot actively process them.

    reply
    0
  • Cancelreply