Skip to content

Commit a5d6ff8

Browse files
authored
Merge pull request #234 from sendbird/feat/bump-minimum-expo-media-library-version
[CLNP-6592] refactor: bump minimum expo-media-library version for android policy compliance
2 parents 4181505 + 71fedf0 commit a5d6ff8

File tree

3 files changed

+37
-56
lines changed

3 files changed

+37
-56
lines changed

packages/uikit-react-native/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"expo-file-system": "^15.2.2",
8484
"expo-image-manipulator": "^11.1.1",
8585
"expo-image-picker": "^14.1.1",
86-
"expo-media-library": "^15.2.3",
86+
"expo-media-library": "^16.0.0",
8787
"expo-notifications": "^0.18.1",
8888
"expo-video-thumbnails": "^7.2.1",
8989
"glob": "^7.2.0",
@@ -121,6 +121,7 @@
121121
"expo-image-manipulator": ">=11.0.0",
122122
"expo-image-picker": ">=12.0.2",
123123
"expo-notifications": ">=0.14.1",
124+
"expo-media-library": ">=16.0.0",
124125
"expo-video-thumbnails": ">=6.4.0",
125126
"react": ">=17.0.2",
126127
"react-native": ">=0.65.0",
@@ -177,6 +178,9 @@
177178
"expo-notifications": {
178179
"optional": true
179180
},
181+
"expo-media-library": {
182+
"optional": true
183+
},
180184
"expo-video-thumbnails": {
181185
"optional": true
182186
},

packages/uikit-react-native/src/platform/createFileService.expo.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,36 @@ const createExpoFileService = ({
3434
const res = (await imagePickerModule.getCameraPermissionsAsync()) as ExpoPermissionResponse;
3535
return expoPermissionGranted([res]);
3636
}
37+
3738
async requestCameraPermission(): Promise<boolean> {
3839
const res = (await imagePickerModule.requestCameraPermissionsAsync()) as ExpoPermissionResponse;
3940
return expoPermissionGranted([res]);
4041
}
41-
async hasMediaLibraryPermission(type: 'write' | 'read'): Promise<boolean> {
42+
43+
async hasMediaLibraryReadPermission(): Promise<boolean> {
4244
const perms = (await imagePickerModule.getMediaLibraryPermissionsAsync(
43-
type === 'write',
45+
false,
4446
)) as ExpoMediaLibraryPermissionResponse;
4547
return expoPermissionGranted([perms]);
4648
}
47-
async requestMediaLibraryPermission(type: 'write' | 'read'): Promise<boolean> {
49+
50+
async requestMediaLibraryReadPermission(): Promise<boolean> {
4851
const perms = (await imagePickerModule.requestMediaLibraryPermissionsAsync(
49-
type === 'write',
52+
false,
5053
)) as ExpoMediaLibraryPermissionResponse;
5154
return expoPermissionGranted([perms]);
5255
}
5356

57+
async hasMediaLibraryWritePermission(): Promise<boolean> {
58+
const perms = (await mediaLibraryModule.getPermissionsAsync(true, [])) as ExpoMediaLibraryPermissionResponse;
59+
return expoPermissionGranted([perms]);
60+
}
61+
62+
async requestMediaLibraryWritePermission(): Promise<boolean> {
63+
const perms = (await mediaLibraryModule.requestPermissionsAsync(true, [])) as ExpoMediaLibraryPermissionResponse;
64+
return expoPermissionGranted([perms]);
65+
}
66+
5467
async openCamera(options?: OpenCameraOptions): Promise<FilePickerResponse> {
5568
const hasPermission = await this.hasCameraPermission();
5669
if (!hasPermission) {
@@ -81,10 +94,11 @@ const createExpoFileService = ({
8194
const [file] = await expoBackwardUtils.imagePicker.toFilePickerResponses(response, fsModule);
8295
return file;
8396
}
97+
8498
async openMediaLibrary(options: OpenMediaLibraryOptions) {
85-
const hasPermission = await this.hasMediaLibraryPermission('read');
99+
const hasPermission = await this.hasMediaLibraryReadPermission();
86100
if (!hasPermission) {
87-
const granted = await this.requestMediaLibraryPermission('read');
101+
const granted = await this.requestMediaLibraryReadPermission();
88102
if (!granted) {
89103
options?.onOpenFailure?.(SBUError.PERMISSIONS_DENIED);
90104
return null;
@@ -125,9 +139,9 @@ const createExpoFileService = ({
125139
}
126140

127141
async save(options: SaveOptions): Promise<string> {
128-
const hasPermission = await this.hasMediaLibraryPermission('write');
142+
const hasPermission = await this.hasMediaLibraryWritePermission();
129143
if (!hasPermission) {
130-
const granted = await this.requestMediaLibraryPermission('write');
144+
const granted = await this.requestMediaLibraryWritePermission();
131145
if (!granted) throw new Error('Permission not granted');
132146
}
133147

@@ -142,6 +156,7 @@ const createExpoFileService = ({
142156
}
143157
return response.uri;
144158
}
159+
145160
createRecordFilePath(customExtension = 'm4a'): { recordFilePath: string; uri: string } {
146161
const basePath = fsModule.cacheDirectory;
147162
if (!basePath) throw new Error('Cannot determine directory');

yarn.lock

Lines changed: 9 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@
12371237
"@babel/parser" "^7.25.9"
12381238
"@babel/types" "^7.25.9"
12391239

1240-
"@babel/traverse--for-generate-function-map@npm:@babel/traverse@^7.25.3":
1240+
"@babel/traverse--for-generate-function-map@npm:@babel/traverse@^7.25.3", "@babel/traverse@^7.1.0", "@babel/traverse@^7.13.0", "@babel/traverse@^7.20.0", "@babel/traverse@^7.25.3", "@babel/traverse@^7.25.9", "@babel/traverse@^7.7.0", "@babel/traverse@^7.7.4":
12411241
version "7.25.9"
12421242
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.25.9.tgz#a50f8fe49e7f69f53de5bea7e413cd35c5e13c84"
12431243
integrity sha512-ZCuvfwOwlz/bawvAuvcj8rrithP2/N55Tzz342AkTvq4qaWbGfmCk/tKhNaV2cthijKrPAA8SRJV5WWe7IBMJw==
@@ -1266,19 +1266,6 @@
12661266
debug "^4.1.0"
12671267
globals "^11.1.0"
12681268

1269-
"@babel/traverse@^7.1.0", "@babel/traverse@^7.13.0", "@babel/traverse@^7.20.0", "@babel/traverse@^7.25.3", "@babel/traverse@^7.25.9", "@babel/traverse@^7.7.0", "@babel/traverse@^7.7.4":
1270-
version "7.25.9"
1271-
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.25.9.tgz#a50f8fe49e7f69f53de5bea7e413cd35c5e13c84"
1272-
integrity sha512-ZCuvfwOwlz/bawvAuvcj8rrithP2/N55Tzz342AkTvq4qaWbGfmCk/tKhNaV2cthijKrPAA8SRJV5WWe7IBMJw==
1273-
dependencies:
1274-
"@babel/code-frame" "^7.25.9"
1275-
"@babel/generator" "^7.25.9"
1276-
"@babel/parser" "^7.25.9"
1277-
"@babel/template" "^7.25.9"
1278-
"@babel/types" "^7.25.9"
1279-
debug "^4.3.1"
1280-
globals "^11.1.0"
1281-
12821269
"@babel/types@7.17.0":
12831270
version "7.17.0"
12841271
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.17.0.tgz#a826e368bccb6b3d84acd76acad5c0d87342390b"
@@ -3293,7 +3280,7 @@
32933280
resolved "https://registry.yarnpkg.com/@react-native-community/slider/-/slider-4.5.5.tgz#d70fc5870477760033769bbd6625d57e7d7678b2"
32943281
integrity sha512-x2N415pg4ZxIltArOKczPwn7JEYh+1OxQ4+hTnafomnMsqs65HZuEWcX+Ch8c5r8V83DiunuQUf5hWGWlw8hQQ==
32953282

3296-
"@react-native-documents/picker@^10.0.0":
3283+
"@react-native-documents/picker@^10.0.0", "@react-native-documents/picker@^10.1.0":
32973284
version "10.1.2"
32983285
resolved "https://registry.yarnpkg.com/@react-native-documents/picker/-/picker-10.1.2.tgz#2ebbf1eccc7e9efa3690e35ab5f0a811411a57b8"
32993286
integrity sha512-JzbFmFp0SmG0FEKt4Q62trewHMFpas2zAX0n5EANwrU9kondnzAEF7/xxz2EA2tfZNwnkHelqG8A7iedGleMRw==
@@ -8091,10 +8078,10 @@ expo-image-picker@^14.1.1:
80918078
dependencies:
80928079
expo-image-loader "~4.6.0"
80938080

8094-
expo-media-library@^15.2.3:
8095-
version "15.9.2"
8096-
resolved "https://registry.yarnpkg.com/expo-media-library/-/expo-media-library-15.9.2.tgz#cf7183db639a3065862ed0696a315e946d5812a0"
8097-
integrity sha512-ExRcCxNO768aWPQr9axuBDQLcFnRTSiqvWZ1XvnopCfZEic04wJ/CPAE1hLqTp7AyYrd6jHpqxa/aNKBAAFVeA==
8081+
expo-media-library@^16.0.0:
8082+
version "16.0.5"
8083+
resolved "https://registry.yarnpkg.com/expo-media-library/-/expo-media-library-16.0.5.tgz#5827f237f4425088bdb15f1f0949916613d0ae3d"
8084+
integrity sha512-O9RUqBWgJVRF0mO6EiLSBFyfb5wR1/ZqovbT43V0TAo5sgcjrHRs+0NID/U6BWDRuiFeX2AU516JgNDutNUFSw==
80988085

80998086
expo-notifications@^0.18.1:
81008087
version "0.18.1"
@@ -15080,16 +15067,7 @@ string-natural-compare@^3.0.1:
1508015067
resolved "https://registry.yarnpkg.com/string-natural-compare/-/string-natural-compare-3.0.1.tgz#7a42d58474454963759e8e8b7ae63d71c1e7fdf4"
1508115068
integrity sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw==
1508215069

15083-
"string-width-cjs@npm:string-width@^4.2.0":
15084-
version "4.2.3"
15085-
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
15086-
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
15087-
dependencies:
15088-
emoji-regex "^8.0.0"
15089-
is-fullwidth-code-point "^3.0.0"
15090-
strip-ansi "^6.0.1"
15091-
15092-
"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
15070+
"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
1509315071
version "4.2.3"
1509415072
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
1509515073
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -15195,7 +15173,7 @@ string_decoder@~1.1.1:
1519515173
dependencies:
1519615174
safe-buffer "~5.1.0"
1519715175

15198-
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
15176+
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
1519915177
version "6.0.1"
1520015178
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
1520115179
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -15209,13 +15187,6 @@ strip-ansi@^5.0.0, strip-ansi@^5.2.0:
1520915187
dependencies:
1521015188
ansi-regex "^4.1.0"
1521115189

15212-
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
15213-
version "6.0.1"
15214-
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
15215-
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
15216-
dependencies:
15217-
ansi-regex "^5.0.1"
15218-
1521915190
strip-ansi@^7.0.1:
1522015191
version "7.1.0"
1522115192
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
@@ -16408,7 +16379,7 @@ worker-farm@^1.7.0:
1640816379
dependencies:
1640916380
errno "~0.1.7"
1641016381

16411-
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
16382+
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
1641216383
version "7.0.0"
1641316384
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
1641416385
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
@@ -16426,15 +16397,6 @@ wrap-ansi@^6.0.1, wrap-ansi@^6.2.0:
1642616397
string-width "^4.1.0"
1642716398
strip-ansi "^6.0.0"
1642816399

16429-
wrap-ansi@^7.0.0:
16430-
version "7.0.0"
16431-
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
16432-
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
16433-
dependencies:
16434-
ansi-styles "^4.0.0"
16435-
string-width "^4.1.0"
16436-
strip-ansi "^6.0.0"
16437-
1643816400
wrap-ansi@^8.1.0:
1643916401
version "8.1.0"
1644016402
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"

0 commit comments

Comments
 (0)