Reputation: 53
I am trying to integrate CallKit into my Voip app. I referred to the SpeakerBox sample code from Apple WWDC. I created a ProviderDelegate class and I am able to see the incoming call UI after calling reportNewIncomingCall
method.
But when I tap on the "Answer"/"End" button, the respective provider delegates are not fired. What could be wrong here?
Please note that "providerDidBegin
" is called when I instantiate the CallProviderDelegate
.
@implementation CallProviderDelegate
- (instancetype)init
{
self = [super init];
if (self) {
_providerConfiguration = [self getProviderConfiguration];
_provider = [[CXProvider alloc] initWithConfiguration:_providerConfiguration];
[_provider setDelegate:self queue:nil];
}
return self;
}
- (void)providerDidBegin:(CXProvider *)provider {
// this is getting called
}
- (void)provider:(CXProvider *)provider performAnswerCallAction:(CXAnswerCallAction *)action {
// this is not getting called when the Answer button is pressed
}
- (void)reportNewIncomingCallWithUUID:(nonnull NSUUID *)UUID handle:(nonnull NSString *)handle
completion:(nullable void (^)(NSError *_Nullable error))completion {
CXCallUpdate *update = [[CXCallUpdate alloc] init];
update.remoteHandle = [[CXHandle alloc] initWithType:CXHandleTypePhoneNumber value:handle];
update.hasVideo = NO;
[_provider reportNewIncomingCallWithUUID:UUID update:update completion:^(NSError * _Nullable error) {
completion(error);
}];
}
In Caller Class:
CallProviderDelegate *providerDelegate = [[CallProviderDelegate alloc] init];
[providerDelegate reportNewIncomingCallWithUUID:[NSUUID UUID] handle:@"Raj" completion:^(NSError * _Nullable error) {
//
}];
Upvotes: 2
Views: 2633
Reputation: 11588
In your "caller" class, i.e. the code in which you instantiate the CallProviderDelegate
class and assign it to the providerDelegate
variable, are you storing the providerDelegate
object reference in an instance variable or property? If it is only being assigned to a temporary local variable, then the CallProviderDelegate
object will be deallocated after the calling method finishes executing, and if the CallProviderDelegate
object is deallocated then no further CXProvider delegate messages will be delivered.
I'd check that your CallProviderDelegate
object is not being accidentally deallocated first.
Upvotes: 3