iOS 13中的VoIP传入呼叫上的本地蜂窝呼叫失败

时间:2019-09-26 12:41:55

标签: objective-c voip ios13 callkit pushkit

我已经在iOS中使用VoIP PushKit实现了用于音频和视频通话的CallKit,并且在iOS 12和更低版本中均能正常运行,并且在iOS 13和13.1中也能正常运行。

但是在两种情况下失败了:

1)我们的应用程序处于前台状态。当蜂窝电话正在运行并且收到VoIP推送时,呼叫工具包的来电屏幕将显示5-10秒钟,然后蜂窝电话和VOIP呼叫都会失败,并显示警报“呼叫失败”。

2)我们的应用处于后台或已终止状态。当蜂窝电话正在运行并且收到VoIP推送时,蜂窝电话和VOIP呼叫都会失败,并显示警报“呼叫失败”。这次没有显示来电界面。

我在这里显示我的代码:

- (void)registerAppForVOIPPush {

    PKPushRegistry *pushRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
    pushRegistry.delegate = self;
    pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
}

然后推送代表

#pragma mark PKPushRegistryDelegate ----

- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials: (PKPushCredentials *)credentials forType:(NSString *)type {

    NSString *newToken = [self hexadecimalStringFromData:credentials.token];
    //Make a note of this token to a server to send VOIP for a particular device
    NSLog(@"VOIP token ::: %@", newToken);
    _voipToken = newToken;
}

- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type {
    //available(iOS, introduced: 8.0, deprecated: 11.0)
    [self pushRegistryDidReceivedPushWithPayload:payload forType:type withCompletionHandler:NULL];
}

- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion {
    //available(iOS 11.0, *)
    [self pushRegistryDidReceivedPushWithPayload:payload forType:type withCompletionHandler:completion];
}

- (void)pushRegistryDidReceivedPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion {

    //Call kit configration
    CXProviderConfiguration *providerConfig = [[CXProviderConfiguration alloc] initWithLocalizedName:@"my app Call"];
    providerConfig.supportsVideo = NO;
    providerConfig.maximumCallGroups = 1;
    providerConfig.maximumCallsPerCallGroup = 1;
    providerConfig.supportedHandleTypes = [[NSSet alloc] initWithObjects:[NSNumber numberWithInteger:CXHandleTypeGeneric], nil];
    providerConfig.iconTemplateImageData = UIImagePNGRepresentation([UIImage imageNamed:@"IconMask"]);


    CXProvider *provider = [[CXProvider alloc] initWithConfiguration:providerConfig];
    [provider setDelegate:self queue:nil];

    //generate token
    NSUUID *callbackUUIDToken = [NSUUID UUID];

    //Display callkit

    NSString *uniqueIdentifier = @"Max test";
    CXCallUpdate *update = [[CXCallUpdate alloc] init];
    update.remoteHandle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:uniqueIdentifier];
    update.supportsGrouping = FALSE;
    update.supportsUngrouping = FALSE;
    update.supportsHolding = FALSE;
    update.localizedCallerName = uniqueIdentifier;
    update.hasVideo = NO;
    [provider reportNewIncomingCallWithUUID:callbackUUIDToken update:update completion:^(NSError * _Nullable error) {
        NSLog(@"reportNewIncomingCallWithUUID error: %@",error);
    }];

    if (completion) {
        dispatch_async(dispatch_get_main_queue(), ^{
            completion();
        });
    }
}

我已经完美实现了CXProvider委托方法

- (void)provider:(CXProvider *)provider performAnswerCallAction:(CXAnswerCallAction *)action{
    [action fulfill];
}

- (void)provider:(CXProvider *)provider performEndCallAction:(CXEndCallAction *)action{
    [action fulfill];
}

并管理其他委托方法来管理调用和所有操作,并且在所有条件下均能完美运行。

我已经使用其他应用程序(例如Google Duo,Whatsapp和FaceTime)检查了这两种情况,并且可以正确显示CallKit,但是在我的应用程序中却失败了。我不知道它哪里失败了。

因此,对于iOS 13及更高版本,我有这2个问题。任何帮助将不胜感激。 谢谢。

3 个答案:

答案 0 :(得分:4)

这可能是iOS 13的错误,如果尚未完成,应将其报告给Apple。

我认为类似Whatapp(和我开发的应用程序)之类的应用程序能够运行的原因是,我们是根据iOS 12 SDK构建该应用程序的。我们这样做是由于iOS 13中引入的VoIP推送通知的局限性。因此,您可以尝试根据iOS 12 SDK解决此问题(至少直到2020年4月)。希望苹果公司能尽快解决此问题。

答案 1 :(得分:0)

我认为您可以看到Apple最新视频 https://developer.apple.com/videos/play/wwdc2019/707关于此问题 如果可以解决,请ping https://github.com/saroar

答案 2 :(得分:0)

@Max我遇到了与iOS 13.0至13.2.0版相同的问题。

许多开发人员已向Apple报告了此问题。上周发布的最新iOS版本(iOS 13.2.2)已解决此错误。因此,现在,您可以从最新的SDK和xCode 11.2.1开始工作,而不是从较早的SDK进行构建。