Flutter permission_handler 권한 플러그 인의 사용 에 대한 자세 한 설명

컴 파일 환경:Flutter 버 전 v 1.12.hotfix 9 dart SDK:2.7.2
1 pubspec.yaml 에 도입:
  #  권한
  permission_handler: ^3.2.0
ios 에서 info.plist 설정(권한 상황 에 따라 사용):

 <!-- Permission options for the `location` group -->
 <key>NSLocationWhenInUseUsageDescription</key>
 <string>Need location when in use</string>
 <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
 <string>Always and when in use!</string>
 <key>NSLocationUsageDescription</key>
 <string>Older devices need location.</string>
 <key>NSLocationAlwaysUsageDescription</key>
 <string>Can I haz location always?</string>

 <!-- Permission options for the `mediaLibrary` group -->
 <key>NSAppleMusicUsageDescription</key>
 <string>Music!</string>
 <key>kTCCServiceMediaLibrary</key>
 <string>media</string>

 <!-- Permission options for the `calendar` group -->
 <key>NSCalendarsUsageDescription</key>
 <string>Calendars</string>

 <!-- Permission options for the `camera` group -->
 <key>NSCameraUsageDescription</key>
 <string>camera</string>

 <!-- Permission options for the `contacts` group -->
 <key>NSContactsUsageDescription</key>
 <string>contacts</string>

 <!-- Permission options for the `microphone` group -->
 <key>NSMicrophoneUsageDescription</key>
 <string>microphone</string>

 <!-- Permission options for the `speech` group -->
 <key>NSSpeechRecognitionUsageDescription</key>
 <string>speech</string>

 <!-- Permission options for the `sensors` group -->
 <key>NSMotionUsageDescription</key>
 <string>motion</string>

 <!-- Permission options for the `photos` group -->
 <key>NSPhotoLibraryUsageDescription</key>
 <string>photos</string>

 <!-- Permission options for the `reminder` group -->
 <key>NSRemindersUsageDescription</key>
 <string>reminders</string>
2.코드 의 구체 적 인 사용:

 void chosePhoto(int index) async {
 PermissionHandler().requestPermissions(
 [PermissionGroup.photos, PermissionGroup.camera]).then((map) {
 if (map[PermissionGroup.photos] == PermissionStatus.granted ||
  map[PermissionGroup.camera] == PermissionStatus.granted) {
 chosePhotoFromPhone(context, index);
 }
 });
 }
3.요약:
사용 하 는 과정 에서 안 드 로 이 드 X 나 Swift 언어 가 어 울 릴 수 있 으 므 로 이 때 는 구체 적 인 상황 에 따라 수정 해 야 합 니 다.
Flutter permissionhandler 권한 플러그 인 사용 에 관 한 글 은 여기까지 입 니 다.Flutter permissionhandler 권한 플러그 인 내용 은 우리 의 이전 글 을 검색 하거나 아래 의 관련 글 을 계속 찾 아 보 세 요.앞으로 도 많은 응원 부 탁 드 리 겠 습 니 다!

좋은 웹페이지 즐겨찾기