Call: Check permissions before accessing to the camera and the microphone.

It is particularly useful when a perm has been denied.
This commit is contained in:
manuroe
2016-07-29 17:59:59 +02:00
parent 764a299df1
commit f53190557f
2 changed files with 22 additions and 20 deletions
@@ -235,32 +235,18 @@ static void *RecordingContext = &RecordingContext;
- (void)checkDeviceAuthorizationStatus
{
NSString *mediaType = AVMediaTypeVideo;
[AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) {
if (!granted)
{
// Not granted access to mediaType
__weak typeof(self) weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
alert = [[MXKAlert alloc] initWithTitle:nil message:NSLocalizedStringFromTable(@"camera_access_not_granted", @"Vector", nil) style:MXKAlertStyleAlert];
alert.cancelButtonIndex = [alert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"ok"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
__strong __typeof(weakSelf)strongSelf = weakSelf;
strongSelf->alert = nil;
}];
[alert showInViewController:self];
});
}
else
[MXKTools checkAccessForMediaType:AVMediaTypeVideo manualChangeMessage:NSLocalizedStringFromTable(@"camera_access_not_granted", @"Vector", nil) showPopUpInViewController:self completionHandler:^(BOOL granted) {
if (granted)
{
// Load recent captures if this is not already done
if (!recentCaptures.count)
{
dispatch_async(dispatch_get_main_queue(), ^{
[self reloadRecentCapturesCollection];
[self reloadUserLibraryAlbums];
});
}
}
+17 -1
View File
@@ -1823,7 +1823,23 @@
- (void)roomInputToolbarView:(MXKRoomInputToolbarView*)toolbarView placeCallWithVideo:(BOOL)video
{
[self.mainSession.callManager placeCallInRoom:self.roomDataSource.roomId withVideo:video];
NSString *appDisplayName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"];
// Check app permissions before placing the call
[MXKTools checkAccessForCall:video
manualChangeMessageForAudio:[NSString stringWithFormat:[NSBundle mxk_localizedStringForKey:@"microphone_access_not_granted_for_call"], appDisplayName]
manualChangeMessageForVideo:[NSString stringWithFormat:[NSBundle mxk_localizedStringForKey:@"camera_access_not_granted_for_call"], appDisplayName]
showPopUpInViewController:self completionHandler:^(BOOL granted) {
if (granted)
{
[self.mainSession.callManager placeCallInRoom:self.roomDataSource.roomId withVideo:video];
}
else
{
NSLog(@"RoomViewController: Warning: The application does not have the perssion to place the call");
}
}];
}
- (void)roomInputToolbarView:(MXKRoomInputToolbarView*)toolbarView heightDidChanged:(CGFloat)height completion:(void (^)(BOOL finished))completion