Apple のオペレーティングシステムは、アプリケーションが機密情報やデバイス機能にアクセスする前に承認をリクエストすることを義務付けています。アプリケーションがデバイスの カメラ、マイク、位置情報などの機能にアクセスする必要がある場合は、必ず、デバイスのユーザーが、アプリケーションにアクセス許可を与える必要があります。
iOS デバイスにおける認証リクエストの詳細は、Apple のドキュメント を参照してください。
アプリケーションが必要とするデバイス機能にアクセスするためには、以下を行う必要があります。
機能の使用目的の説明 (“目的の文字列” とも呼ばれます) は、アプリケーションがデバイス機能にアクセスしようとした時に iOS システムによって表示されるメッセージです。アプリケーションがアクセスを行う理由を明確に記述することが推奨されます。
機能の使用目的の説明は、Player 設定 の Configuration セクション (メニュー: Edit > Project Settings > Player > Other Settings) で入力できます。Player 設定に使用目的の説明を追加すると、それが key (キー) と value (値) のペアとして info.plist ファイル内に追加されます。例えば、アプリケーションがデバイスの カメラ へのアクセスを必要とする場合は、Player 設定の Camera Usage Description (カメラの使用目的の説明) に入力します。入力された説明は自動的に NSCameraUsageDescription キー の値として info.plist ファイル内に表示されます。詳細は iOS Player 設定の Apple 特有の情報 を参照してください。
代替方法として、info.plist ファイルに直接、必要な機能の使用説明のキーと値のペアを追加することもできます。
機能の使用目的の説明を追加したら、Application.RequestUserAuthorization メソッドを使用して カメラ やマイクへのアクセスのリクエストを送信します。システムによって、承認リクエストに関する説明ダイアログが表示されます。
この API の使用方法を示すサンプルコードは、Application.RequestUserAuthorizationを で参照してください。
デバイスの位置情報へのアクセスについては、LocationService APIを参照してください。
リクエストの承認状況は、Application.HasUserAuthorization メソッドを使用して確認できます。
ノート: デバイスのユーザーは、デバイスの設定から、機能のアクセス許可状況をいつでも変更することができます。Application.HasUserAuthorization メソッドを使用して、機能にアクセスする前にその機能のアクセス許可状況を確認することができます。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.