Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 当通话为视频时,在CallKit来电屏幕中显示视频按钮_Ios_Video_Callkit_Incoming Call - Fatal编程技术网

Ios 当通话为视频时,在CallKit来电屏幕中显示视频按钮

Ios 当通话为视频时,在CallKit来电屏幕中显示视频按钮,ios,video,callkit,incoming-call,Ios,Video,Callkit,Incoming Call,我使用以下代码来接收视频通话。我的应用程序具有音频和视频通话功能,我正在使用linphone+CallKit - (void)config { CXProviderConfiguration *config = [[CXProviderConfiguration alloc] initWithLocalizedName:[NSBundle.mainBundle objectForInfoDictionaryKe

我使用以下代码来接收视频通话。我的应用程序具有音频和视频通话功能,我正在使用linphone+CallKit

- (void)config {
    CXProviderConfiguration *config = [[CXProviderConfiguration alloc]
                                       initWithLocalizedName:[NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleName"]];
    config.ringtoneSound = @"notes_of_the_optimistic.caf";

    config.supportsVideo = TRUE;

    config.iconTemplateImageData = UIImagePNGRepresentation([UIImage imageNamed:@"callkit_logo"]);


    NSArray *ar = @[ [NSNumber numberWithInt:(int)CXHandleTypeGeneric] ];

    NSSet *handleTypes = [[NSSet alloc] initWithArray:ar];
    [config setSupportedHandleTypes:handleTypes];

    [config setMaximumCallGroups:2];
    [config setMaximumCallsPerCallGroup:1];


    self.provider = [[CXProvider alloc] initWithConfiguration:config];
    [self.provider setDelegate:self queue:dispatch_get_main_queue()];
}



- (void)reportIncomingCall:(LinphoneCall *) call withUUID:(NSUUID *)uuid handle:(NSString *)handle video:(BOOL)video
{
    CXCallUpdate *update = [[CXCallUpdate alloc] init];
    update.remoteHandle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:handle];
    update.supportsDTMF = TRUE;
    update.supportsHolding = TRUE;
    update.supportsGrouping = TRUE;
    update.supportsUngrouping = TRUE;
    update.hasVideo = video;
    linphone_call_ref(call);
    // Report incoming call to system
    LOGD(@"CallKit: report new incoming call");

    [self.provider reportNewIncomingCallWithUUID:uuid
                                          update:update
                                      completion:^(NSError *error) {
                                          if (error) {
                                              LOGE(@"CallKit: cannot complete incoming call from [%@] caused by [%@]",handle,[error localizedDescription]);
                                              if (   [error code] == CXErrorCodeIncomingCallErrorFilteredByDoNotDisturb
                                                  || [error code] == CXErrorCodeIncomingCallErrorFilteredByBlockList) {
                                                  linphone_call_decline(call,LinphoneReasonBusy); /*to give a chance for other devices to answer*/
                                              } else {
                                                  linphone_call_decline(call,LinphoneReasonUnknown);
                                              }
                                          }
                                          linphone_call_unref(call);
                                      }];
}
请参阅附带的视频来电界面截图。它为音频和视频通话显示相同的UI(按钮)。当通话为视频通话时,我想显示视频通话按钮。可以使用CallKit吗?如果可能,需要进行哪些更改?提前谢谢


没有,很遗憾,无法自定义CallKit来电用户界面。这就是WhatsApp等应用程序使用推送通知通知视频通话的原因,而不是依赖CallKit。

请查看此演示。CallKit有一个属性
supportsVideo
CXProviderConfiguration
和一个属性
hasVideo
CXHandle
。 这对我来说很好。检查下面的演示链接

所以只需在
ProviderDelegate.swift
文件中进行如下修改

    static var providerConfiguration: CXProviderConfiguration {
        let localizedName = NSLocalizedString("CallKitDemo", comment: "Name of application")
        let providerConfiguration = CXProviderConfiguration(localizedName: localizedName)

        providerConfiguration.supportsVideo = true. //For Video Call Enable
        
        providerConfiguration.includesCallsInRecents = false; //Show hide from phone recent call history
        
        providerConfiguration.maximumCallsPerCallGroup = 1

        providerConfiguration.supportedHandleTypes = [.phoneNumber]

        providerConfiguration.iconTemplateImageData = #imageLiteral(resourceName: "IconMask").pngData()

        providerConfiguration.ringtoneSound = "Ringtone.caf"
        
        return providerConfiguration
    }
和reportIncomingCall()

    static var providerConfiguration: CXProviderConfiguration {
        let localizedName = NSLocalizedString("CallKitDemo", comment: "Name of application")
        let providerConfiguration = CXProviderConfiguration(localizedName: localizedName)

        providerConfiguration.supportsVideo = true. //For Video Call Enable
        
        providerConfiguration.includesCallsInRecents = false; //Show hide from phone recent call history
        
        providerConfiguration.maximumCallsPerCallGroup = 1

        providerConfiguration.supportedHandleTypes = [.phoneNumber]

        providerConfiguration.iconTemplateImageData = #imageLiteral(resourceName: "IconMask").pngData()

        providerConfiguration.ringtoneSound = "Ringtone.caf"
        
        return providerConfiguration
    }
func reportIncomingCall(uuid: UUID, handle: String, hasVideo: Bool = false, completion: ((NSError?) -> Void)? = nil) {
        // Construct a CXCallUpdate describing the incoming call, including the caller.
        let update = CXCallUpdate()
        update.remoteHandle = CXHandle(type: .phoneNumber, value: handle)
        update.hasVideo = hasVideo //For Video Call available or not

        // pre-heat the AVAudioSession
        //OTAudioDeviceManager.setAudioDevice(OTDefaultAudioDevice.sharedInstance())
        
        // Report the incoming call to the system
        provider.reportNewIncomingCall(with: uuid, update: update) { error in
            /*
                Only add incoming call to the app's list of calls if the call was allowed (i.e. there was no error)
                since calls may be "denied" for various legitimate reasons. See CXErrorCodeIncomingCallError.
             */
            if error == nil {
                let call = SpeakerboxCall(uuid: uuid)
                call.handle = handle

                self.callManager.addCall(call)
            }
            
            completion?(error as NSError?)
        }
    }