注册

关于视频聊天的问题

我在集成了EaseUI3.0后,发现对于视频聊天的请求,如果用户选择了不给权限,那么虽然应用会提示我们去隐私-》相机然后后找到相应的应用打开权限,但我测试发现在列表中并没有列出来我们的app。经过查找,感觉问题在CallViewController.m的canVideo方法。这里对能否访问摄像头进行了判断,但没有尝试去获取权限。因此我将代码修改为如下内容。完美解决这个问题。
+ (BOOL)canVideo
{
if([[[UIDevice currentDevice] systemVersion] compare:@"7.0"] != NSOrderedAscending){
// if(!([AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo] == AVAuthorizationStatusAuthorized)){\
// UIAlertView * alt = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"setting.cameraNoAuthority", @"No camera permissions") message:NSLocalizedString(@"setting.cameraAuthority", @"Please open in \"Setting\"-\"Privacy\"-\"Camera\".") delegate:self cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"ok", @"OK"), nil];
// [alt show];
// return NO;
// }
NSString *mediaType = AVMediaTypeVideo;// Or AVMediaTypeAudio
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];
NSLog(@"---cui--authStatus--------%d",authStatus);
// This status is normally not visible—the AVCaptureDevice class methods for discovering devices do not return devices the user is restricted from accessing.
if(authStatus ==AVAuthorizationStatusRestricted){
NSLog(@"Restricted");
}else if(authStatus == AVAuthorizationStatusDenied){
// The user has explicitly denied permission for media capture.
NSLog(@"Denied"); //应该是这个,如果不允许的话
UIAlertView * alt = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"setting.cameraNoAuthority", @"No camera permissions") message:NSLocalizedString(@"setting.cameraAuthority", @"Please open in \"Setting\"-\"Privacy\"-\"Camera\".") delegate:self cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"ok", @"OK"), nil];
[alt show];
return NO;
}
else if(authStatus == AVAuthorizationStatusAuthorized){//允许访问
// The user has explicitly granted permission for media capture, or explicit user permission is not necessary for the media type in question.
NSLog(@"Authorized");

}else if(authStatus == AVAuthorizationStatusNotDetermined){
// Explicit user permission is required for media capture, but the user has not yet granted or denied such permission.
[AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) {
if(granted){//点击允许访问时调用
//用户明确许可与否,媒体需要捕获,但用户尚未授予或拒绝许可。
NSLog(@"Granted access to %@", mediaType);
}
else {
NSLog(@"Not granted access to %@", mediaType);
}

}];
}else {
NSLog(@"Unknown authorization status");
}
}

return YES;
}

4 个评论

赞呀~\(≧▽≦)/~
赞赏16元
shutup

shutup 回复 fat1

thx
shutup

shutup 回复 beyond

也是遇到了。

要回复文章请先登录注册