不会触发CXProviderDelegate方法

时间:2016-10-04 06:29:04

标签: ios objective-c callkit

我正在尝试将CallKit集成到我的Voip应用程序中。我提到了Apple WWDC的SpeakerBox示例代码。我创建了一个ProviderDelegate类,我可以在调用reportNewIncomingCall方法后看到传入的调用UI。

但是当我点击"答案" /"结束"按钮,相应的提供者代表不会被解雇。这可能有什么问题?

请注意" providerDidBegin"在我实例化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);
    }]; 
}

在来电者班:

CallProviderDelegate *providerDelegate = [[CallProviderDelegate alloc] init];
[providerDelegate reportNewIncomingCallWithUUID:[NSUUID UUID] handle:@"Raj" completion:^(NSError * _Nullable error) {
            //
 }];

1 个答案:

答案 0 :(得分:2)

在你的"来电者" class,即实例化CallProviderDelegate类并将其分配给providerDelegate变量的代码,是否将providerDelegate对象引用存储在实例变量或属性中?如果仅将其分配给临时局部变量,则在调用方法完成执行后将释放CallProviderDelegate对象,如果释放CallProviderDelegate对象,则不会再传递任何CXProvider委托消息

我检查您的CallProviderDelegate对象是否未被意外取消分配。