[英]Detect when user press Cancel - telprompt - objective-c
I have seen this question before but without any real answer. 我之前看过这个问题,但没有任何实际答案。
I am using the following code to start a phone call in objective-c. 我正在使用以下代码在Objective-C中打个电话。
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt:1234567890"]]
This code opens a dialog with the telephone number, an Abort button and a Call button. 此代码将打开一个包含电话号码,中止按钮和呼叫按钮的对话框。
Does anyone know how to detect if the Cancel button was pressed? 有谁知道如何检测是否按下了取消按钮?
I need to do some special arrangements in app if Cancel is pressed. 如果按取消,我需要在应用程序中做一些特殊的安排。
I have tried to use a UIAlertView
combined with the @"tel:1234567890"
command, but that isn't any good. 我试图将
UIAlertView
与@"tel:1234567890"
命令结合使用,但这没什么用。 If the "tel:"
command is used, the user will leave the app which isn't what I want... 如果使用
"tel:"
命令,则用户将离开我不想要的应用程序...
Thanks! 谢谢!
/Henrik /亨里克
I think is possible to make guess which button user selected in call prompt. 我认为可以猜测用户在呼叫提示中选择了哪个按钮。
After you call openURL:
your app receive [AppDelegate applicationWillResignActive:]
method call. 调用
openURL:
您的应用程序会收到[AppDelegate applicationWillResignActive:]
方法调用。
Then possible two cases: 然后可能出现两种情况:
If user select Call you get [AppDelegate applicationDidEnterBackground:]
because phone app will open. 如果用户选择“ 呼叫”,则会得到
[AppDelegate applicationDidEnterBackground:]
因为电话应用程序将打开。
If user select Cancel you get [AppDelegate applicationDidBecomeActive:]
method call. 如果用户选择“ 取消”,则会得到
[AppDelegate applicationDidBecomeActive:]
方法调用。
I think you can implement some singleton to save app state and update it in this methods. 我认为您可以实现一些单例来保存应用程序状态并通过此方法对其进行更新。
Good luck 祝好运
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.