Как я могу предотвратить сброс приложений IOS после изменения разрешений (таких как микрофон, камера, фото)?

Мой вопрос похож на " Как я могу предотвратить сброс приложений iOS после изменения разрешений камеры? ". Но я не очень хорошо понимаю ответ.

Я установил разрешение микрофона по коду:

- (BOOL) canRecord {__block BOOL bCanRecord = NO;
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType: AVMediaTypeAudio];

if (authStatus == AVAuthorizationStatusRestricted || authStatus ==AVAuthorizationStatusDenied)

{
    //prompt
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"setting permission" message:@"need microphone permission" preferredStyle:UIAlertControllerStyleAlert];

    UIAlertAction *settingAction = [UIAlertAction actionWithTitle:@"setting now" style:UIAlertActionStyleDefault handler:^(UIAlertAction * a){
        // jump to setting
        NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
        if ([[UIApplication sharedApplication] canOpenURL:url]) {

            if ([[[UIDevice currentDevice]systemVersion]floatValue]>10.0) {

                [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
            } else {
                [[UIApplication sharedApplication] openURL:url];
            } 
        }
    }];

    UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"later" style:UIAlertActionStyleDefault handler:nil];
    [alertController addAction:settingAction];
    [alertController addAction:okAction];

    [self presentViewController:alertController animated:YES completion:nil];

}else{

    if ([[[UIDevice currentDevice]systemVersion]floatValue] >= 7.0) {
        AVAudioSession *audioSession = [AVAudioSession sharedInstance];
        [audioSession performSelector:@selector(requestRecordPermission:) withObject:^(BOOL granted) {
            if (granted) {
                bCanRecord = YES;
            } else {
                bCanRecord = NO;
            }
        }];
        //        }
    }
    NSLog(@"bCanRecord %d",bCanRecord);

}

return bCanRecord;

}

затем вернитесь в мое приложение, нажав клавишу возврата в строке состояния, мое приложение выполнит принудительное обновление, и я потеряю свое место в приложении.

Я использую iPhone5 под управлением IOS 9.3.3.

0 ответов

Другие вопросы по тегам