有没有办法判断用户打电话时是否正在使用您的应用程序?

发布于 08-07 15:58 字数 105 浏览 10 评论 0原文

如果用户正在打电话,我的应用程序的某些部分最好向他们突出显示。

是否可以打电话确认我们是否在通电话?不幸的是,出于显而易见的原因,在 API 文档中检查“call”是一个可怕的词。

There are certain portions of my app that would be better to highlight to the user if they're on the phone.

Is there a call to check to see if we're on the phone? Unfortunately, "call" is a horrible word to check for in API documents for obvious reasons.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

倾城°AllureLove2024-08-14 15:58:10

看一下 [[UIScreen mainScreen]bounds][[UIScreen mainScreen] applicationFrame] 之间的大小差异。如果差异为 20 像素并且您没有隐藏状态栏,则用户可能没有在通话。如果差异为 40 像素,则您的用户可能正在通话,因为通话期间出现的发光绿色状态栏大约是正常状态栏的两倍。

我以前没有这样做过,所以 YMMV。祝你好运,让我知道它是否有效!

Take a look at the difference in size between [[UIScreen mainScreen] bounds] and [[UIScreen mainScreen] applicationFrame]. If the diff is 20 pixels and you aren't hiding the status bar, then the users probably isn't on a call. If the difference is 40 pixels, your users is probably on a call, since the glowing green status bar that appears during calls is about twice as big as the normal status bar.

I haven't done this before, so YMMV. Good luck and let me know if it works!

客…行舟2024-08-14 15:58:10

CoreTelephony 框架可以告诉您。

CTCallCenter currentCalls 方法返回一组当前活动的蜂窝呼叫。

The CoreTelephony Framework can tell you.

The CTCallCenter currentCalls method returns a set of currently active cellular calls.

蓝色星空2024-08-14 15:58:10

当有呼叫进入时,应用程序不会退出,而是会转换为非活动状态。应在 UIApplicationDelegate< 上调用以下方法/a>:

- (void)applicationWillResignActive:(UIApplication *)application

在其他情况下也会调用此方法,例如当 iPhone 被锁定时,您无法确定是否是来电导致的。

The application does not exit when a call comes in, it transitions to an inactive state. The following method should be called on the UIApplicationDelegate:

- (void)applicationWillResignActive:(UIApplication *)application

This method is also called in other cases, such as when the iPhone is locked, and you have no way of determining if it was an incoming phone call that caused it.

彼岸花似海2024-08-14 15:58:10

当 iPhone 接到电话时,应用程序退出。您可以注册回调来优雅地处理此事件,请参阅:

http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm /UIApplicationDelegate/applicationWillTerminate

调用完成后,您的应用程序将重新启动。

在通话期间保留您的状态的应用程序写得很好:)


啊!我刚刚读了你的实际问题。

我找不到,也不知道有任何 API 可以访问手机应用程序。我唯一的建议是,Phone 是一个像任何其他应用程序一样的应用程序 - 它可以通过所有应用程序提供的 http 隧道发布信息。

我想知道是否可以只提供一个“我正在打电话”按钮,让用户按下即可达到相同的结果?

When the iPhone receives a call, the application exits. You can register a callback to handle this event gracefully, see:

http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/applicationWillTerminate:

After the call has finished, your application will re-launch.

Applications that appear to preserve your state during a call are just written well :)


Arggh! I just read your actual question.

I cannot find, nor do I know of any APIs to access the phone application. My only advice would be that Phone is an application like any other - and it can publish information via the http tunnel all applications provide.

I wonder if you could just have an "I'm on the phone" button the user could press to achieve the same results?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文