有没有办法判断用户打电话时是否正在使用您的应用程序?
如果用户正在打电话,我的应用程序的某些部分最好向他们突出显示。
是否可以打电话确认我们是否在通电话?不幸的是,出于显而易见的原因,在 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 技术交流群。

发布评论
评论(4)
蓝色星空2024-08-14 15:58:10
当有呼叫进入时,应用程序不会退出,而是会转换为非活动状态。应在 UIApplicationDelegate< 上调用以下方法/a>:
- (void)applicationWillResignActive:(UIApplication *)application
在其他情况下也会调用此方法,例如当 iPhone 被锁定时,您无法确定是否是来电导致的。
彼岸花似海2024-08-14 15:58:10
当 iPhone 接到电话时,应用程序退出。您可以注册回调来优雅地处理此事件,请参阅:
调用完成后,您的应用程序将重新启动。
在通话期间保留您的状态的应用程序写得很好:)
啊!我刚刚读了你的实际问题。
我找不到,也不知道有任何 API 可以访问手机应用程序。我唯一的建议是,Phone 是一个像任何其他应用程序一样的应用程序 - 它可以通过所有应用程序提供的 http 隧道发布信息。
我想知道是否可以只提供一个“我正在打电话”按钮,让用户按下即可达到相同的结果?
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
看一下
[[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!