Skip to content

Commit 7f31104

Browse files
authored
Merge pull request #211 from sendbird/fix/android-permissions
[CLNP-5556] fix: remove non-required permissions from android
2 parents d1ddb87 + 4646e34 commit 7f31104

File tree

4 files changed

+18
-22
lines changed

4 files changed

+18
-22
lines changed

packages/uikit-react-native/README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,15 @@ Add the following permissions to your `android/app/src/main/AndroidManifest.xml`
7676
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
7777
package="com.your.app">
7878

79-
<uses-permission android:name="android.permission.CAMERA" />
79+
<!-- Permissions for voice message -->
8080
<uses-permission android:name="android.permission.RECORD_AUDIO" />
81+
82+
<!-- Permissions for image attachments -->
8183
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
8284
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
85+
86+
<!-- Permissions for notifications (Android 13) -->
8387
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
84-
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
85-
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
86-
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
8788

8889
</manifest>
8990
```

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

+2-6
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ function getAndroidStoragePermissionsByAPILevel(permissionModule: typeof Permiss
3131
if (Platform.OS !== 'android') return [];
3232

3333
if (Platform.Version > 32) {
34-
return [
35-
permissionModule.PERMISSIONS.ANDROID.READ_MEDIA_AUDIO,
36-
permissionModule.PERMISSIONS.ANDROID.READ_MEDIA_IMAGES,
37-
permissionModule.PERMISSIONS.ANDROID.READ_MEDIA_VIDEO,
38-
];
34+
return [];
3935
}
4036

4137
if (Platform.Version > 28) {
@@ -63,7 +59,7 @@ const createNativeFileService = ({
6359
}): FileServiceInterface => {
6460
const cameraPermissions: Permission[] = Platform.select({
6561
ios: [permissionModule.PERMISSIONS.IOS.CAMERA, permissionModule.PERMISSIONS.IOS.MICROPHONE],
66-
android: [permissionModule.PERMISSIONS.ANDROID.CAMERA],
62+
android: [],
6763
default: [],
6864
});
6965
const mediaLibraryPermissions: Permission[] = Platform.select({

packages/uikit-react-native/src/platform/createPlayerService.native.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,15 @@ const createNativePlayerService = ({ audioRecorderModule, permissionModule }: Mo
5858

5959
public requestPermission = async (): Promise<boolean> => {
6060
if (Platform.OS === 'android') {
61-
const { READ_MEDIA_AUDIO, READ_EXTERNAL_STORAGE } = permissionModule.PERMISSIONS.ANDROID;
62-
const permission = Platform.Version > 32 ? READ_MEDIA_AUDIO : READ_EXTERNAL_STORAGE;
61+
if (Platform.Version > 32) return true;
6362

64-
const status = await permissionModule.check(permission);
63+
const { READ_EXTERNAL_STORAGE } = permissionModule.PERMISSIONS.ANDROID;
64+
65+
const status = await permissionModule.check(READ_EXTERNAL_STORAGE);
6566
if (status === 'granted') {
6667
return true;
6768
} else {
68-
const status = await permissionModule.request(permission);
69+
const status = await permissionModule.request(READ_EXTERNAL_STORAGE);
6970
return status === 'granted';
7071
}
7172
} else {

sample/android/app/src/main/AndroidManifest.xml

+6-8
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@
55

66
<uses-permission android:name="android.permission.INTERNET" />
77

8-
<!-- Permissions for FilePickerService -->
9-
<uses-permission android:name="android.permission.CAMERA" />
8+
<!-- Permissions for voice message -->
9+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
10+
11+
<!-- Permissions for image attachments -->
1012
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
1113
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
12-
<!-- Permissions for VoiceMessage -->
13-
<uses-permission android:name="android.permission.RECORD_AUDIO" />
14-
<!-- Android 13 -->
14+
15+
<!-- Permissions for notifications (Android 13) -->
1516
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
16-
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
17-
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
18-
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
1917

2018
<application
2119
android:name=".MainApplication"

0 commit comments

Comments
 (0)