iPhone,拨打另一个电话号码以回应第一个没有回答? [英] iPhone, call another phone number in response to the first not answering?

查看:180
本文介绍了iPhone,拨打另一个电话号码以回应第一个没有回答?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个应用程序,该应用程序将在类似呼叫中心的列表上发起对优先级1联系人的呼叫。

I am attempting to create an application that will initiate a call to a priority 1 contact on a call-center-like list.

然后,如果该联系人确实如此没有回答(让我们忘记在这里回答机器的整个问题),我想打电话给优先级2联系人,依此类推,直到其中一人回答或我耗尽我的名单。

Then, if that contact does not answer (let's forget the whole problem of answering machines here), I'd like to call the priority 2 contact, and so on, until one of them answers or I exhaust my list.

这可能吗?

我尝试过以下方法:


  1. 挂钩进入 CTCallCenter.CallEventHandler 事件,并检查 CTCallStateConnected CTCallStateDisconnected ,我得到它回应这个事实,即呼叫断开,没有连接,然后尝试发起另一个呼叫,就像我做的第一次,但第二次尝试只是在死water。

  2. 覆盖 DidEnterBackground 方法,并定期检查 CTCall.CallState 财产,基本上再次尝试回应到一个从未连接的断开连接,但这似乎不起作用

  1. Hook into the CTCallCenter.CallEventHandler event, and checking the call state for CTCallStateConnected and CTCallStateDisconnected, and I get it to respond to the fact that the call disconnected, without ever connecting, and then attempt to initiate another call like I did the first, but this second attempt just sits dead in the water.
  2. Override the DidEnterBackground method, and periodically check the CTCall.CallState property, basically again trying to respond to a disconnect that was never connected, but this does not appear to work either

我也尝试添加一个短暂的延迟(1秒,在尝试下一次拨号之前检测到断开状态后,2.5秒和10秒),允许电话应用程序在中止呼叫后安顿下来,这没有任何改变。

I also tried adding a short delay (1 second, 2.5 seconds and 10 seconds) after detecting the disconnected state before attempting the next dial, to allow for the phone application to "settle down" after aborting the call, this did not change anything.

推荐答案

我认为这可以在电话目的地更好地解决。我要么让电话公司配置跟我来服务,使用Twilio或其他一些第三方服务(如已经建议的那样),或者使用像星号(Asterisk包括配置跟我来类型行为的能力)。它为您提供了更多的灵活性和控制,即使您确实找到了在iOS中本地执行此操作的方法。

I'm of the opinion that this is better solved at the destination of the phone call. I would either have the phone company configure a "follow me" service, use Twilio or some other 3rd party service (as already suggested), or configure my own PBX using something like Asterisk (Asterisk includes the ability to configure "follow me" type behavior). It provides you much more flexibility and control, even if you did find a way to do this natively in iOS.

话虽如此,我确实让它在iOS中运行假设如下:

Having said that, I did get this to work in iOS assuming the following:


  1. 您的应用程序发起呼叫。

  2. 手机应用程序已打开,拨打数字和断开连接。

  3. 用户明确返回到您的应用。如果您在应用程序背景时设法获取事件,我想知道更多: - )。

  4. 将控制权返还给您的应用程序时,会发送电话事件并发送新电话已启动。

  1. Your app initiates the call.
  2. The phone app is opened, dials the number, and disconnects.
  3. The user explicitly returns to your app. If you managed to get the events while your app was backgrounded, I want to know more :-).
  4. On return of control to your app, the phone events are sent and a new call is initiated.

我在UIApplicationDelegate didFinishLaunchingWithOptions方法中有以下代码片段:

I have the following snippet of code in my UIApplicationDelegate didFinishLaunchingWithOptions method:

// In appdelegate header, ct is declared as @property (strong, nonatomic) CTCallCenter *ct; 
self.ct = [[CTCallCenter alloc] init];
self.ct.callEventHandler = ^(CTCall *call) {
    if (call.callState == CTCallStateConnected) {
        // do some state management to track the call
    } else if (call.callState == CTCallStateDisconnected) {
        // check that this is the expected call and setup the
        // new phone number
        NSURL *telURL = [NSURL URLWithString:myNewNumberURL];
        [application openURL:telURL];    
    }     
};

这将进行新的通话。我正在使用iOS 5 SDK;在iPhone 4s上测试过。

This will make the new call. I'm using the iOS 5 SDK; tested on an iPhone 4s.

编辑

使用在本机代码中电话呼叫与UIWebView不同后返回应用行为作为一个起点,我设法让这个工作。请注意,为了清晰起见,我对内存管理进行了抨击。假设您在呼叫完成后使用网络视图技术返回您的应用,请在呼叫已完成的阻止中尝试以下内容:

Using Return to app behavior after phone call different in native code than UIWebView as a starting point, I've managed to get this to work. Note that I have punted on memory management for clarity. Assuming you use the web view technique for getting back to your app after the call is complete, try something like this in the call completed block:

else if (call.callState == CTCallStateDisconnected) {
    // check that this is the expected call and setup the
    // new phone number
    NSURL *telURL = [NSURL URLWithString:myNewNumberURL];
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWebView *callWebview = [[UIWebView alloc] init]  ;
        [self.window.rootViewController.view addSubview:callWebview];
        [callWebview loadRequest:[NSURLRequest requestWithURL:telURL]]; 
        // and now callWebView sits around until the app is killed....so don't follow this to the letter.  
    });
}

然而,这可能不会给你你想要的东西。用户将收到每个呼叫请求的警报,从而提供取消呼叫的机会。

However, this may not quite give you what you want either. The user will get an alert on each call request, providing an opportunity to cancel the call.

这篇关于iPhone,拨打另一个电话号码以回应第一个没有回答?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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