-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: get current permission #1184
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Caijinglong <[email protected]>
Signed-off-by: Caijinglong <[email protected]>
Signed-off-by: Caijinglong <[email protected]>
Signed-off-by: Caijinglong <[email protected]>
Signed-off-by: Caijinglong <[email protected]>
Signed-off-by: Caijinglong <[email protected]>
Signed-off-by: Caijinglong <[email protected]>
} | ||
} | ||
|
||
- (void)getPermissionState:(ResultHandler *)handler { | ||
int requestAccessLevel = [handler.call.arguments[@"iosAccessLevel"] intValue]; | ||
#if __IPHONE_14_0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the macro required? The minimum Xcode has already supported at least iOS 17.
@@ -63,7 +63,7 @@ enum OrderOptionType { | |||
enum PMRequestState { prepare, loading, success, failed } | |||
|
|||
/// Information about app’s authorization to access the user’s photo library. | |||
/// * Android: Only [authorized] and [denied] are valid. | |||
/// * Android: Have [authorized], [denied] and [limited] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// * Android: Have [authorized], [denied] and [limited] | |
/// * Android: [authorized], [denied], and [limited]. |
PMConstants.mGetPermissionState, | ||
requestOption.toMap(), | ||
); | ||
return PermissionState.values[result ?? 0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any chance that we can get a nullable result here? If not, use the non-nullable return.
/// Get the current permission state of the application | ||
/// | ||
/// This method returns a [Future] that resolves to the current [PermissionState] of the application. | ||
/// | ||
/// Possible values for [PermissionState] include: | ||
/// - [PermissionState.notDetermined]: The user hasn't made a choice yet | ||
/// - [PermissionState.restricted]: The application is restricted from accessing the photo library (iOS only) | ||
/// - [PermissionState.denied]: The user has denied permission | ||
/// - [PermissionState.authorized]: The user has granted full access permission | ||
/// - [PermissionState.limited]: The user has granted limited access permission (iOS 14+ only) | ||
/// | ||
/// Example: | ||
/// ```dart | ||
/// PermissionState state = await PhotoManager.getPermissionState(); | ||
/// if (state == PermissionState.authorized) { | ||
/// print('The application has full access permission'); | ||
/// } else { | ||
/// print('The application does not have full access permission'); | ||
/// } | ||
/// ``` | ||
/// | ||
/// Note: On Android, this method may require an [Activity] context. If called in a background service, | ||
/// make sure to call the [setIgnorePermissionCheck] method first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Get the current permission state of the application | |
/// | |
/// This method returns a [Future] that resolves to the current [PermissionState] of the application. | |
/// | |
/// Possible values for [PermissionState] include: | |
/// - [PermissionState.notDetermined]: The user hasn't made a choice yet | |
/// - [PermissionState.restricted]: The application is restricted from accessing the photo library (iOS only) | |
/// - [PermissionState.denied]: The user has denied permission | |
/// - [PermissionState.authorized]: The user has granted full access permission | |
/// - [PermissionState.limited]: The user has granted limited access permission (iOS 14+ only) | |
/// | |
/// Example: | |
/// ```dart | |
/// PermissionState state = await PhotoManager.getPermissionState(); | |
/// if (state == PermissionState.authorized) { | |
/// print('The application has full access permission'); | |
/// } else { | |
/// print('The application does not have full access permission'); | |
/// } | |
/// ``` | |
/// | |
/// Note: On Android, this method may require an [Activity] context. If called in a background service, | |
/// make sure to call the [setIgnorePermissionCheck] method first. | |
/// Get the current [PermissionState] of the photo library. | |
/// | |
/// Example: | |
/// ```dart | |
/// PermissionState state = await PhotoManager.getPermissionState(); | |
/// if (state == PermissionState.authorized) { | |
/// print('The application has full access permission'); | |
/// } else { | |
/// print('The application does not have full access permission'); | |
/// } | |
/// ``` | |
/// | |
/// Note: On Android, this method may require an [Activity] context. | |
/// Call [setIgnorePermissionCheck] first if the call is from a background service. |
/// - [PermissionState.notDetermined]: The user hasn't made a choice yet | ||
/// - [PermissionState.restricted]: The application is restricted from accessing the photo library (iOS only) | ||
/// - [PermissionState.denied]: The user has denied permission | ||
/// - [PermissionState.authorized]: The user has granted full access permission | ||
/// - [PermissionState.limited]: The user has granted limited access permission (iOS 14+ only) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could state these values in the enum definition.
static Future<PermissionState> getPermissionState({ | ||
PermissionRequestOption requestOption = const PermissionRequestOption(), | ||
}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make requestOption
as a required named parameter? In that way we let developers always have a sense of what they are trying to do and provide valid input.
values.add('audio'); | ||
} | ||
|
||
return '$runtimeType(${values.join(', ')})'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return '$runtimeType(${values.join(', ')})'; | |
return 'RequestType(${values.join(', ')})'; |
No description provided.