iOS 13 中的 VoIP 来电本机蜂窝通话失败

Max*_*Max 8 voip objective-c pushkit callkit ios13

我已经在 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];
}
Run Code Online (Sandbox Code Playgroud)

然后推送代表

#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();
        });
    }
}
Run Code Online (Sandbox Code Playgroud)

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

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

- (void)provider:(CXProvider *)provider performEndCallAction:(CXEndCallAction *)action{
    [action fulfill];
}
Run Code Online (Sandbox Code Playgroud)

并管理其他委托方法来管理呼叫和一切,它在所有条件下都能完美运行。

我已经使用 Google Duo、Whatsapp 和 FaceTime 等其他应用程序检查了这两个场景,它可以正确显示 CallKit 而没有失败,但在我的应用程序中它失败了。我不知道它在哪里失败。

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

Mar*_*rco 4

这可能是 iOS 13 的一个错误,如果您还没有这样做,您应该向 Apple 报告。

\n\n

我认为像 Whatapp(以及我开发的应用程序)这样的应用程序能够正常工作的原因是我们针对 iOS 12 SDK 构建了该应用程序。我们这样做是因为 iOS 13 中引入的 VoIP 推送通知的限制。因此,您可以尝试解决该问题\xe2\x80\x94,至少在 2020 年 4 月之前\xe2\x80\x94针对 iOS 12 SDK 进行构建。希望苹果能够尽快解决这个问题。

\n