如何通过我的应用程序拨打电话时,用户是否按下了“呼叫”或“取消”按钮? [英] How can I find out whether the user pressed the Call or the Cancel button when making a call from my app?

查看:214
本文介绍了如何通过我的应用程序拨打电话时,用户是否按下了“呼叫”或“取消”按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从我的应用程序拨打电话后返回我的应用程序,所以我使用此代码:

I need to return to my app after making a call from my app, so I use this code:

NSURL *url = [NSURL URLWithString:@"telprompt://123-4567-890"]; 
[[UIApplication  sharedApplication] openURL:url]; 

当用户按下按钮执行此代码时,会显示一个警告,其中包含2个按钮,呼叫 和取消。

When the user presses a button to execute this code, an alert is shown with 2 buttons, "Call" and "Cancel".

如何确定用户是否按下呼叫按钮?

How can I find out if the user pressed the "Call" button?

推荐答案

这不是完美的,但你可以通过监听UIApplicationSuspendedNotification来识别call被按下而不是取消(你必须添加一些逻辑来忽略这个事件)当有人按下主页键或正在接听来电时...可能是通过在显示电话号码的逻辑周围添加/删除观察者):

This isn't perfect, but you could identify that "call" was pressed instead of "cancel" by listening for the UIApplicationSuspendedNotification (you'd have to add some logic to ignore this event when someone pushed the 'home' key, or was accepting an incoming call... maybe by adding/removing the observer around the logic where the phone number is being presented):

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(suspended:) name:@"UIApplicationSuspendedNotification" object:nil];

-(void)suspended:(NSNotification *) notification
{
    NSLog(@"Suspended");
}

这篇关于如何通过我的应用程序拨打电话时,用户是否按下了“呼叫”或“取消”按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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