iOS后台服务震动手机 [英] iOS background service vibrate phone

查看:155
本文介绍了iOS后台服务震动手机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在后台运行的应用程序(位置服务)。当应用程序位于前台时,它会在我想要的时候振动很好,但是,如果它不在前台(在多任务处理视图中),则振动不再起作用。这是不允许的?我的后台应用程序是否有某种方式可以提供振动警报?如果不是那个哔哔声呢?

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 (in the multitasking view), the vibrate does not work anymore. Is this not allowed? Is there some way for my background app to give a vibrate alert? If not that what about a beeping sound?

现在我正在做这样的事情:

Right now I am just doing something like this:

    AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

导入时:

#import <AudioToolbox/AudioServices.h>


推荐答案

如果您尝试向用户提供在您的应用在后台运行时通知某些内容,请考虑使用本地通知提供该信息(请参阅 UILocalNotification 。)

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:


  • 一些用户(包括我自己)在静音模式下禁用振动

  • iPad和iPod触摸不振动

  • 用户可能不知道是什么原因导致振动或声音,可能无法实现打开你的应用程序

本地通知以他们可以控制和识别的方式显示给用户。

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.

这篇关于iOS后台服务震动手机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆