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 kno开发者_C百科w 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.
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.
精彩评论