CoreTelephony 框架也可用于 Facetime 吗?
我正在开发一个可与 FaceTime 配合使用的应用程序。不幸的是,目前还没有可用的 Facetime 框架或 API,因此我正在使用现有的框架或 API。正如大家都必须知道的那样,当拨打 Facetime 电话时,本机电话应用程序会完成这项工作。唯一的问题是,当通话结束时,它会保留在那里。
我想要做的是,一旦通话结束,向用户发送本地通知,询问他是否想返回我的应用程序,所有这一切都在 CoreTelephony 框架的帮助下。我知道它是一个正在开发的框架,而且仍然是一个私有框架,但是:
我可以在我的应用程序中使用该框架并发布它,而不会被 Apple 拒绝吗?
该框架也适用于 Facetime 吗?我无法让它发挥作用。 这是我所做的:
- 我首先将框架导入到我的 appDelegate 头文件中
- ,然后
...。
- (void)applicationDidEnterBackground:(UIApplication *)application{
NSLog(@"applicationDidEnterBackground");
CTCallCenter *callCenter = [[CTCallCenter alloc] init];
callCenter.callEventHandler=^(CTCall* call){
if (call.callState == CTCallStateDialing){
NSLog(@"Call Dialing");
}
if (call.callState == CTCallStateConnected){
NSLog(@"Call Connected");
}
if (call.callState == CTCallStateDisconnected){
NSLog(@"Call Disconnected");
}
};
}
什么都没有被追踪到。有什么想法吗?
更新:我刚刚运行了一个小测试,我发现我的代码可以完美地处理实际的电话呼叫。 CTCallCenter 块必须放置在 applicationDidBecomeActive 方法中。我还意识到(就像苹果文档所说的那样),框架仅当您在应用程序中时才会发送这些通知。挂起模式不会收到任何类型的通知。
I'm develloping an app that works with facetime. Unfortunatly, there is not yet Facetime frameworks or APIs available, so I'm working with what I have. Like you all must know, when a Facetime call is placed, the native Phone app does the job. The only problem is that when the call is over, it stays in there.
What I want to do is to, once the call ended, send a local notification to the user to ask if he wants to get back to my app, all this with the help of CoreTelephony framework. I know it is a work-in-progress framework and that it's still a private one, BUT:
Can I use that framework in my app and publish it, without been rejected by Apple?
Does that framework works for Facetime too? I can't get it work.
Here is what I did:
- I first imported the framework in my appDelegate header file
- And then...
.
- (void)applicationDidEnterBackground:(UIApplication *)application{
NSLog(@"applicationDidEnterBackground");
CTCallCenter *callCenter = [[CTCallCenter alloc] init];
callCenter.callEventHandler=^(CTCall* call){
if (call.callState == CTCallStateDialing){
NSLog(@"Call Dialing");
}
if (call.callState == CTCallStateConnected){
NSLog(@"Call Connected");
}
if (call.callState == CTCallStateDisconnected){
NSLog(@"Call Disconnected");
}
};
}
Nothing gets traced. Any ideas?
Update: I just run a little test, I figured out that my code works perfectly with an actual phone call. The CTCallCenter block must be placed in the applicationDidBecomeActive method tho. I also realized that (like the Apple documentation says), the frameworks dispatches those notification only when you're in your app. Suspended mode doesn't get any kind of notification.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
iOS 10 中有一个新的 CallKit SDK,即使没有 VoIP 授权,也可以检测 VoIP 呼叫(包括 FaceTime)。 这是一个很好的答案,解释了如何使用观察者部分。
There's a new CallKit SDK in iOS 10 that allows for detecting of VoIP calls (including FaceTime) even without VoIP entitlements. Here's a great answer explaining how just to use the observer part.