【问题标题】:Native cellular call fails on VoIP incoming call in iOS 13iOS 13 中 VoIP 来电的本机蜂窝呼叫失败
【发布时间】:2019-09-26 12:41:55
【问题描述】:

我已经在 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 个声明的问题。任何帮助将不胜感激。 谢谢。

【问题讨论】:

    标签: objective-c voip ios13 callkit pushkit


    【解决方案1】:

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

    我认为,像 Whatapp(以及我开发的那个)这样的应用之所以能够运行,是因为我们针对 iOS 12 SDK 构建了该应用。我们这样做是因为 iOS 13 中引入的 VoIP 推送通知的限制。因此,您可以尝试在 iOS 12 SDK 构建时解决该问题(至少在 2020 年 4 月之前)。希望 Apple 能尽快解决此问题。

    【讨论】:

    • 好的,我会检查一下,并检查它是否会影响 UI 更改以支持 iOS 13。
    • @Max 你成功了吗?
    • @RushangPrajapati,是的,它奏效了,我在定义的问题上取得了成功。
    • @Max,嗨,Max,你的问题解决了吗,我也有同样的问题..
    • @Steven,问题出在最新的 iOS 或 xcode 11 中,所以我从 xcode 10.2.1 构建了应用程序,它工作正常。我们需要等待更新版本的 iOS 或 xcode 来修复此问题。
    【解决方案2】:

    @Max 我遇到了您在 iOS 版本 13.0 到 13.2.0 中遇到的同样问题。

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

    【讨论】:

    • 好的,感谢您的更新。我会检查最新的 Xcode。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多