一、Android端:
1、确保gradle.properties
文件有以下配置
ini
android.useAndroidX=true
android.enableJetifier=true
2、确保android/app/build.gradle
的 compileSdkVersion到31
二、iOS端:
1、Podfile文件配置
ruby
# 权限配置开始
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
## 仅允许写入日历的权限(iOS 16 及以下)
# 'PERMISSION_EVENTS=1',
## 允许完全访问日历的权限(iOS 17及以上)
# 'PERMISSION_EVENTS_FULL_ACCESS=1',
## 提醒事项权限
# 'PERMISSION_REMINDERS=1',
## 联系人权限
# 'PERMISSION_CONTACTS=1',
## 相机权限
# 'PERMISSION_CAMERA=1',
## 麦克风权限
# 'PERMISSION_MICROPHONE=1',
## 语音识别权限
# 'PERMISSION_SPEECH_RECOGNIZER=1',
## 照片权限
# 'PERMISSION_PHOTOS=1',
## 位置权限组(包括始终、使用中)
# 'PERMISSION_LOCATION=1',
## 通知权限
# 'PERMISSION_NOTIFICATIONS=1',
## 媒体库权限
# 'PERMISSION_MEDIA_LIBRARY=1',
## 传感器权限
# 'PERMISSION_SENSORS=1',
## 蓝牙权限
# 'PERMISSION_BLUETOOTH=1',
## 应用跟踪透明度权限
# 'PERMISSION_APP_TRACKING_TRANSPARENCY=1',
## 关键警报权限
# 'PERMISSION_CRITICAL_ALERTS=1'
]
# 权限配置结束
end
2、Info.plist里的权限要正常添加
- 日历权限(< iOS 17) NSCalendarsUsageDescription PERMISSION_EVENTS
- 日历写权限(iOS 17+) NSCalendarsWriteOnlyAccessUsageDescription PERMISSION_EVENTS
- 日历完全访问权限(iOS 17+) NSCalendarsFullAccessUsageDescription PERMISSION_EVENTS_FULL_ACCESS
- 提醒事项权限 NSRemindersUsageDescription PERMISSION_REMINDERS
- 联系人权限 NSContactsUsageDescription PERMISSION_CONTACTS
- 相机权限 NSCameraUsageDescription PERMISSION_CAMERA
- 相册权限 NSPhotoLibraryAddUsageDescription -
- 麦克风权限 NSMicrophoneUsageDescription PERMISSION_MICROPHONE
- 语音识别权限 NSSpeechRecognitionUsageDescription PERMISSION_SPEECH_RECOGNIZER
- 照片权限 NSPhotoLibraryUsageDescription PERMISSION_PHOTOS
- 位置权限 NSLocationUsageDescription, PERMISSION_LOCATION
- 始终使用位置权限 NSLocationAlwaysAndWhenInUseUsageDescription PERMISSION_NOTIFICATIONS
- 仅在使用时使用位置权限 NSLocationWhenInUseUsageDescription PERMISSION_NOTIFICATIONS
- 通知权限 PermissionGroupNotification PERMISSION_NOTIFICATIONS
三、PermissionStatus类型介绍
arduino
enum PermissionStatus {
/// The user denied access to the requested feature.
denied, //权限被拒绝
/// The user granted access to the requested feature.
granted, //通过
/// The OS denied access to the requested feature. The user cannot change
/// this app's status, possibly due to active restrictions such as parental
/// controls being in place.
/// *Only supported on iOS.*
restricted, //IOS
///User has authorized this application for limited access.
/// *Only supported on iOS (iOS14+).*
limited, //IOS
/// The user denied access to the requested feature and selected to never
/// again show a request for this permission. The user may still change the
/// permission status in the settings.
/// *Only supported on Android.*
permanentlyDenied, //拒绝,且不在提示
}