iOS background service vibrate phone

后端 未结 4 1374
醉酒成梦
醉酒成梦 2020-12-17 23:39

I have an app that runs in the background (location services). When the app is in the foreground it vibrates fine when I want it to, however, if its not in the foreground (i

相关标签:
4条回答
  • 2020-12-18 00:05

    I'm pretty sure that you aren't able to vibrate the phone while it is in the background state. I've actually never seen an app do this.

    0 讨论(0)
  • 2020-12-18 00:11

    I found that checking 'Audio,AirPlay and Picture in Picture' within the 'Background Modes' of your apps Capabilities worked:

    0 讨论(0)
  • 2020-12-18 00:18

    If you're trying to provide the user with a notification of something while your app is running in the background, consider delivering that information using a Local Notification (see UILocalNotification.)

    Forcing the phone to vibrate is not a great user experience for a few reasons:

    • Some users (including myself) disable vibrate while in silent mode
    • iPads and iPod Touches do not vibrate
    • Users may not know what caused the vibration or sound and may not realize to open your app

    Local notifications appear to the user in a manner that they can control and will recognize.

    If your intention is something besides notifying the user, add that to your question & I'll try to help.

    0 讨论(0)
  • 2020-12-18 00:26

    If you enable background audio modes (as documented by Apple at https://developer.apple.com/library/prerelease/ios//qa/qa1668/_index.html) then vibration will happen when the app is in the background state. I just verified that adding the "App plays audio or streams audio/video using AirPlay" entry under the "Required background modes" property in the target's properties allows the vibration to work when the app is not in the foreground.

    0 讨论(0)
提交回复
热议问题