2016-07-08 9 views
20

私のアプリでは、クレジットカードをスキャンするためにcard.ioを使用しています。それはiOS 9で正常に動作します。iOS 10では、アプリケーションがクラッシュしていて、xcode 8 beta 2コンソールにクラッシュログが見つかりません。ガベージメッセージが多く表示されます。requestAccessForMediaTypeがiOS 10でクラッシュする

次に、私のアプリのカメラが無効になっているかどうかを確認するため、私のアプリはそのセクションには表示されていません。私のアプリがカメラを使用するための許可を求めていません。

私は許可を要求するために、次のコードを使用します。私はこのコードを実行すると

-(BOOL)checkCameraPermissions{ 

    AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; 
    if(authStatus == AVAuthorizationStatusAuthorized) 
    { 
     // start card-io 
     return YES; 
    } 
    else if(authStatus == AVAuthorizationStatusNotDetermined) 
    { 

     [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) 
     { 
      if(granted) 
      { 
       //Start card-io 
       [self testIsNewCard]; 
      } 

     }]; 
    } 
    else if (authStatus == AVAuthorizationStatusRestricted) 
    { 
     //Alert 
     // Alert camera denied 

     UIAlertController *aCon=[UIAlertController alertControllerWithTitle:@"Camera denied" message:@"Camera cannot be used" preferredStyle:UIAlertControllerStyleAlert]; 
     UIAlertAction *ok =[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { 
      [aCon dismissViewControllerAnimated:YES completion:nil]; 
     }]; 
     [aCon addAction:ok]; 
     [self presentViewController:aCon animated:YES completion:nil]; 

     return NO; 

    } 

    return NO; 

} 

、authStatusはAVAuthorizationStatusNotDetermined

として返され、アプリが、それはブロックrequestAccessForMediaType:AVMediaTypeVideo

に入った直後に墜落しました

コンソールに表示されるガベージログが非常に多く、クラッシュメッセージを見つける手がかりがありません。

編集:私もバックトレースのデバッグを無効にした後、任意のクラッシュログを8回答here.を掲載しかし、まだXcodeのがあったしませんでしたXcodeですべての不要なログを無効にするオプションを発見しました。

マイxcode8はちょうどこのメッセージが表示され、アプリがちょうど終了します

App[1124:226447] [access] <private> 

私はまた、メディアへのアクセスを要求しようとしたときの位置とプライバシー、それでもアプリのクラッシュをリセットしてみました。

これは何が起こっているのですか?

+0

これにはどんな解決策がありましたか? –

+0

いいえ、私はまだそれを理解しようとしています –

+0

ちょうどあなたのように私は任意のクラッシュログを取得していない! –

答えて

27

私は"Privacy - Camera Usage Description"キーをinfo.plistファイルに追加しました。

+0

これまでに私がこれを追加したのは奇妙で、前回はうまくいきませんでしたが、今はうまくいきました。 –

+1

驚くばかりの答え! iOS 10にはそれが必要です。 –

10

iOS 10では、すべてのユーザープライベートデータ型へのアクセスを宣言する必要があります。これを行うには、アプリのInfo.plistに使用キーを追加します。詳細は以下のスクリーンショットをご覧ください。

プライバシー - カメラの使用説明をアプリのInfo.plistのキーとその使用情報に追加する必要があります。

詳細については、下記のGIFをご覧ください。

GIF

それとも、Info.plistファイルを経由して追加したい場合、あなたはNSCameraUsageDescriptionキーを追加する必要があります。

info.plistに下の文字列をコピーして貼り付けてください。

<key>NSCameraUsageDescription</key> 
<string>Take the photo</string> 

詳細については、下記のGIFをご覧ください。詳細については

GIF

linkを確認してください。

7

iOS 10はプライバシーポリシーを継続し、新しいプライバシールールを実装しています。そして私たちは次のプロジェクトでそれらを実装することを忘れないでください。あなたは以下info.plist

<!-- Camera --> 
<key>NSCameraUsageDescription</key> 
<string><Your description goes here></string> 

に次の行を追加する必要があり、あなたの問題のために

はプライバシー規則の残りの部分です:

<!-- Photo Library --> 
<key>NSPhotoLibraryUsageDescription</key> 
<string><Your description goes here></string> 

<!-- Camera --> 
<key>NSCameraUsageDescription</key> 
<string><Your description goes here></string> 

<!-- Microphone --> 
<key>NSMicrophoneUsageDescription</key> 
<string><Your description goes here></string> 

<!-- Location --> 
<key>NSLocationUsageDescription</key> 
<string><Your description goes here></string> 

<!-- Location When In Use --> 
<key>NSLocationWhenInUseUsageDescription</key> 
<string><Your description goes here></string> 

<!-- Location Always --> 
<key>NSLocationAlwaysUsageDescription</key> 
<string><Your description goes here></string> 

<!-- Calendars --> 
<key>NSCalendarsUsageDescription</key> 
<string><Your description goes here></string> 

<!-- ⏰ Reminders --> 
<key>NSRemindersUsageDescription</key> 
<string><Your description goes here></string> 

<!-- Motion --> 
<key>NSMotionUsageDescription</key> 
<string><Your description goes here></string> 

<!-- Health Update --> 
<key>NSHealthUpdateUsageDescription</key> 
<string><Your description goes here></string> 

<!-- Health Share --> 
<key>NSHealthShareUsageDescription</key> 
<string><Your description goes here></string> 

<!-- ᛒ Bluetooth Peripheral --> 
<key>NSBluetoothPeripheralUsageDescription</key> 
<string><Your description goes here></string> 

<!-- Media Library --> 
<key>NSAppleMusicUsageDescription</key> 
<string><Your description goes here></string> 

この情報がお役に立てば幸いです。 :)

+0

複数のカメラを使用する場合はどうなりますか?私たちはQRコードを持っているし、セルフ機能を持っているようです。 「このアプリは複数の機能にカメラを使用しています」 – byJeevan

+0

はい、それはあなたが一度定義する必要がある場所の許可を求めるのと同じですし、複数の目的で複数回使用できる場合よりも、あなたのアクセス許可に関する一般的な説明が必要です。 –

関連する問題