iPhone,拨打另一个电话号码以响应第一个电话号码未接听?

发布于 2024-12-24 19:18:59 字数 571 浏览 3 评论 0 原文

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

然后,如果该联系人没有应答(让我们忘记这里应答机的整个问题),我想呼叫优先级 2 联系人,依此类推,直到其中一个联系人应答或我用完我的列表。

这可能吗?

我尝试了以下操作:

  1. 挂钩 CTCallCenter.CallEventHandler 事件,并检查 CTCallStateConnectedCTCallStateDisconnected 的呼叫状态,我明白了响应呼叫已断开且从未连接的事实,然后尝试像第一次一样发起另一个呼叫,但第二次尝试只是停滞不前。
  2. 重写 DidEnterBackground 方法,并定期检查 CTCall.CallState 属性,基本上再次尝试响应从未连接过的断开连接,但这似乎

不起作用还尝试在尝试下一次拨号之前检测到断开连接状态后添加短暂的延迟(1秒、2.5秒和10秒),以允许电话应用程序在中止呼叫后“稳定下来”,但这并没有改变任何东西。

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

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.

Is this possible?

I've tried the following:

  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

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.

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

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

发布评论

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

评论(5

拔了角的鹿 2024-12-31 19:18:59

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

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

  1. 您的应用程序发起呼叫。
  2. 电话应用程序打开,拨打号码,然后断开连接。
  3. 用户明确返回到您的应用程序。如果您在应用程序处于后台时设法获取事件,我想了解更多:-)。
  4. 将控制权返回到您的应用程序后,将发送电话事件并发起新呼叫。

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

// 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 上进行测试。

编辑

使用在本机代码中与 UIWebView 不同的电话呼叫后返回应用程序行为 作为起点,我已设法使其正常工作。请注意,为了清楚起见,我已经把重点放在了内存管理上。假设您在呼叫完成后使用 Web 视图技术返回应用程序,请在呼叫完成块中尝试类似的操作:

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.  
    });
}

但是,这可能也无法满足您的需求。用户将收到有关每个呼叫请求的警报,从而提供取消呼叫的机会。

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.

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

  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.

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];    
    }     
};

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

EDIT:

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.

从此见与不见 2024-12-31 19:18:59

您可以使用http://labs.twilio.com/twimlets/findme。您可以让应用程序呼叫 Twilio 号码,它可以使用 findme 按顺序呼叫所有号码。

You could use http://labs.twilio.com/twimlets/findme. You could have the app call a Twilio number and it could use findme to call all the numbers in order.

溺孤伤于心 2024-12-31 19:18:59

我没有深入研究它,但德国电信 SDK 可能包含您正在寻找的内容:

http://www.developergarden.com/fileadmin/microsites/ApiProject/Dokumente/Dokumentation/ObjectiveC-SDK-2.0/en/interface_voice_call_service.html

但我真的不确定(不要目前没有时间真正查看它) - 我只是记得我在某处读到过他们有一个 iOS SDK,应该也可以处理呼叫管理,所以我发布了链接在这里供您查找(并希望告诉我们它是否有效)。

I didn't take a deeper look at it, but the Deutsche Telekom SDK might contain what you're looking after:

http://www.developergarden.com/fileadmin/microsites/ApiProject/Dokumente/Dokumentation/ObjectiveC-SDK-2.0/en/interface_voice_call_service.html

I really am not sure though (don't have time to really look at it at the moment) - I just remembered I'd read somewhere that they have an iOS SDK that is supposed to also handle call management, so I'm posting the link here for you to find out (and hopefully tell us if it works).

一城柳絮吹成雪 2024-12-31 19:18:59
#pragma mark -
#pragma mark Call Handler Notification
-(void)notificationCallHandler {

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callReceived:) name:CTCallStateIncoming object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callEnded:) name:CTCallStateDisconnected object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callConnected:) name:CTCallStateConnected object:nil];

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

}

-(void)callReceived:(NSNotification*)notification {
     NSLog(@"callReceived");
}
-(void)callConnected:(NSNotification*)notification {
     NSLog(@"callConnected");
}

愿这对你有帮助

#pragma mark -
#pragma mark Call Handler Notification
-(void)notificationCallHandler {

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callReceived:) name:CTCallStateIncoming object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callEnded:) name:CTCallStateDisconnected object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callConnected:) name:CTCallStateConnected object:nil];

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

}

-(void)callReceived:(NSNotification*)notification {
     NSLog(@"callReceived");
}
-(void)callConnected:(NSNotification*)notification {
     NSLog(@"callConnected");
}

May this will help you

笑着哭最痛 2024-12-31 19:18:59

如果您想在应用程序处于后台时设置新的呼叫,我没有看到任何正确的方法,可能是一个小黑客,获取位置更新(因为您可以在应用程序处于后台时获取位置更新),并自动定位服务当新的位置数据到达时唤醒您的应用程序,并且为应用程序提供少量的时间,您可以在其中执行一些代码,在这段时间内您可以开始新的调用。

您可以在这里进一步阅读:
在此链接中搜索“启动重大更改位置服务”位置感知编程指南
,并阅读代码块后面写入的段落。

if you wanna setup a new call, while app is in background, i dont see any proper way for this, a lil hack could be, getting location update (because u can get location updates while app is in background), and location service automatically wakes up your application when new location data arrives, and small amount of time is given to application in which u can execute some code, in that time you may start a new call.

u can read further here:
search this ''Starting the Significant-Change Location Service'' in this link Location Aware programming guide
, and read the paragraph that is written after the code block.

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