Reputation: 79
I searched all over the net but found nothing.
I have an app which run on background. When a call comes my apps quits. and when I disconnect the call it doesn't continue.
Is their any way by which i can resume back my app when call disconnects.
Upvotes: 0
Views: 259
Reputation: 3811
You can resume back your app by using call handling methods:
In header file add this files:
#import<CoreTelephony/CTCarrier.h>
#import <CoreTelephony/CTCallCenter.h>
#import <CoreTelephony/CTCall.h>
@property (nonatomic, strong) CTCallCenter* callCenter;
//Method to handle calls in implementation file
-(void)handleCall
{
self.callCenter.callEventHandler = ^(CTCall *call){
if ([call.callState isEqualToString: CTCallStateConnected])
{
NSLog(@"call CTCallStateConnected");
}
else if ([call.callState isEqualToString: CTCallStateDialing])
{
NSLog(@"call CTCallStateDialing");
}
else if ([call.callState isEqualToString: CTCallStateDisconnected])
{
//resume back your app background method
NSLog(@"call CTCallStateDisconnected");
}
else if ([call.callState isEqualToString: CTCallStateIncoming])
{
NSLog(@"call CTCallStateIncoming");
}
else {
NSLog(@"call NO");
}
};
}
//in appdelegate.m , add handleCall method here
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
[self handleCall];
}
Upvotes: 2