@@ -3,10 +3,10 @@ import { Platform, PermissionsAndroid } from 'react-native';
33import type { Rationale } from 'react-native/Libraries/PermissionsAndroid/PermissionsAndroid' ;
44import { CameraRoll } from '@react-native-camera-roll/camera-roll' ;
55import RNFetchBlob from 'rn-fetch-blob' ;
6- import invariant from 'invariant' ;
76
87import type { Auth } from '../api/transportTypes' ;
98import { getMimeTypeFromFileExtension } from '../utils/url' ;
9+ import { androidSdkVersion } from '../reactNativeUtils' ;
1010
1111/**
1212 * Request permission WRITE_EXTERNAL_STORAGE if needed or throw if can't get it.
@@ -18,17 +18,7 @@ import { getMimeTypeFromFileExtension } from '../utils/url';
1818 * as a toast.
1919 */
2020export const androidEnsureStoragePermission = async ( rationale : Rationale ) : Promise < void > => {
21- invariant (
22- Platform . OS === 'android' ,
23- 'androidEnsureStoragePermission should only be called on Android' ,
24- ) ;
25- // Flow isn't refining `Platform` to a type that corresponds to values
26- // we'll see on Android. We do expect `Platform.Version` to be a number on
27- // Android; see https://reactnative.dev/docs/platform#version. Empirically
28- // (and this isn't in the doc yet), it's the SDK version, so for Android
29- // 10 it won't be 10, it'll be 29.
30- const androidSdkVersion = ( Platform . Version : number ) ;
31- if ( androidSdkVersion > 28 ) {
21+ if ( androidSdkVersion ( ) > 28 ) {
3222 return ;
3323 }
3424
0 commit comments