2

描述

pushkit 委托 didReceiveIncomingPushWithPayload 中的 Voip 呼叫在后台状态下工作正常。但是在被杀死的状态下它不起作用,应用程序在main.m中崩溃。即使在杀死状态下,方法didReceiveIncomingPushWithPayload也不会被调用。

- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion
{
    NSLog(@"<<<<<<<<<<<<<<************* %s",__PRETTY_FUNCTION__);
    NSLog(@"payload.dictionaryPayload = %@",payload.dictionaryPayload);
    NSLog(@"UTC payload.dictionaryPayload = %f",[[NSDate date] timeIntervalSince1970]);

    if (type == PKPushTypeVoIP) {

        //Call kit configration
        CXProviderConfiguration *providerConfig = [[CXProviderConfiguration alloc] initWithLocalizedName:@"Push Voip Call"];
        providerConfig.supportsVideo = NO;
        providerConfig.supportedHandleTypes = [[NSSet alloc] initWithObjects:[NSNumber numberWithInteger:CXHandleTypeEmailAddress], nil];

        CXCallUpdate *callUpdate = [CXCallUpdate new];

        NSString *uniqueIdentifier = @"Demo call";
        CXCallUpdate *update = [[CXCallUpdate alloc] init];
        update.remoteHandle = [[CXHandle alloc] initWithType:CXHandleTypeEmailAddress value:uniqueIdentifier];
        update.localizedCallerName = uniqueIdentifier;
        update.hasVideo = NO;

        NSUUID *callId = [NSUUID UUID];

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

        [provider reportNewIncomingCallWithUUID:callId update:callUpdate completion:^(NSError * _Nullable error) {
            NSLog(@"reportNewIncomingCallWithUUID error: %@",error);

            //completion();

        }];

        completion();
    }
}

我无法弄清楚是什么问题。请帮我找出问题所在。

4

0 回答 0