Showing
1 changed file
with
5 additions
and
6 deletions
| @@ -113,18 +113,17 @@ class MethodChannelMobileScanner extends MobileScannerPlatform { | @@ -113,18 +113,17 @@ class MethodChannelMobileScanner extends MobileScannerPlatform { | ||
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | switch (authorizationState) { | 115 | switch (authorizationState) { |
| 116 | - case MobileScannerAuthorizationState.denied: | ||
| 117 | - throw const MobileScannerException( | ||
| 118 | - errorCode: MobileScannerErrorCode.permissionDenied, | ||
| 119 | - ); | ||
| 120 | case MobileScannerAuthorizationState.authorized: | 116 | case MobileScannerAuthorizationState.authorized: |
| 121 | return; // Already authorized. | 117 | return; // Already authorized. |
| 118 | + // Android does not have an undetermined authorization state. | ||
| 119 | + // So if the permission was denied, request it again. | ||
| 120 | + case MobileScannerAuthorizationState.denied: | ||
| 122 | case MobileScannerAuthorizationState.undetermined: | 121 | case MobileScannerAuthorizationState.undetermined: |
| 123 | try { | 122 | try { |
| 124 | - final bool permissionResult = | 123 | + final bool granted = |
| 125 | await methodChannel.invokeMethod<bool>('request') ?? false; | 124 | await methodChannel.invokeMethod<bool>('request') ?? false; |
| 126 | 125 | ||
| 127 | - if (permissionResult) { | 126 | + if (granted) { |
| 128 | return; // Authorization was granted. | 127 | return; // Authorization was granted. |
| 129 | } | 128 | } |
| 130 | 129 |
-
Please register or login to post a comment