Skip to content
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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

CaiJingLong
Copy link
Member

No description provided.

Signed-off-by: Caijinglong <[email protected]>
Copy link

Download apk from here for b309fc1

Copy link

Download apk from here for 77dae33

Signed-off-by: Caijinglong <[email protected]>
Copy link

Download apk from here for b2a3005

Signed-off-by: Caijinglong <[email protected]>
Copy link

Download apk from here for 8493993

}
}

- (void)getPermissionState:(ResultHandler *)handler {
int requestAccessLevel = [handler.call.arguments[@"iosAccessLevel"] intValue];
#if __IPHONE_14_0
Copy link
Member

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]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// * Android: Have [authorized], [denied] and [limited]
/// * Android: [authorized], [denied], and [limited].

PMConstants.mGetPermissionState,
requestOption.toMap(),
);
return PermissionState.values[result ?? 0];
Copy link
Member

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.

Comment on lines +60 to +82
/// 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// 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.

Comment on lines +65 to +69
/// - [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)
Copy link
Member

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.

Comment on lines +83 to +85
static Future<PermissionState> getPermissionState({
PermissionRequestOption requestOption = const PermissionRequestOption(),
}) {
Copy link
Member

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(', ')})';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return '$runtimeType(${values.join(', ')})';
return 'RequestType(${values.join(', ')})';

@AlexV525 AlexV525 linked an issue Sep 16, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants