Flutter permission for webview/ camera permission flutter
In order to be able to use camera, for example, for taking images through <input type="file" accept="image/*" capture>
HTML tag, you need to ask camera permission. If you need to capture video and audio, you need to ask also microphone permission.
To ask permissions, for this I would recommend to use permission_handler plugin!
Code example:
import 'package:permission_handler/permission_handler.dart';Future main() async {
WidgetsFlutterBinding.ensureInitialized();
await Permission.camera.request();
await Permission.microphone.request(); // if you need microphone permission runApp(MyApp());
}
Configure Android
On Android, you need to add these permissions in your AndroidManifest.xml
file to be able to use camera for taking images and videos:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.VIDEO_CAPTURE" />
<uses-permission android:name="android.permission.AUDIO_CAPTURE" />
Also, you need to add the following code inside the <application>
tag of your AndroidManifest.xml
file:
<provider
android:name="com.pichillilorenzo.flutter_inappwebview.InAppWebViewFileProvider"
android:authorities="${applicationId}.flutter_inappwebview.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
Configure iOS
On iOS, you need to add the following properties in your Info.plist
file to be able to use camera for taking images and videos:
<key>NSMicrophoneUsageDescription</key>
<string>Flutter requires acess to microphone.</string><key>NSCameraUsageDescription</key>
<string>Flutter requires acess to camera.</string>
If you open this file In Xcode, then the NSMicrophoneUsageDescription
property is represented by Privacy - Microphone Usage Description
and NSCameraUsageDescription
is represented by Privacy - Camera Usage Description
.
Important Notes: Apple store require the permission message to be natural and realistic.
You can know more in this page from apple for accessing privacy data