Skip to content

Commit b8b43f8

Browse files
authored
fix(android): remove READ_MEDIA_IMAGES permission to comply with Play Console review (#960)
1 parent 42c3df4 commit b8b43f8

File tree

2 files changed

+31
-93
lines changed

2 files changed

+31
-93
lines changed

app.config.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,7 @@ export default ({ config }: ConfigContext): ExpoConfig => {
3737
android: {
3838
adaptiveIcon: { foregroundImage: './assets/adaptive-icon.png', backgroundColor: '#ffffff' },
3939
package: 'com.chatwoot.app',
40-
permissions: [
41-
'android.permission.CAMERA',
42-
'android.permission.READ_EXTERNAL_STORAGE',
43-
'android.permission.WRITE_EXTERNAL_STORAGE',
44-
'android.permission.RECORD_AUDIO',
45-
'android.permission.READ_MEDIA_IMAGES',
46-
],
40+
permissions: ['android.permission.CAMERA', 'android.permission.RECORD_AUDIO'],
4741
// Please use the relative path to the google-services.json file
4842
googleServicesFile: process.env.EXPO_PUBLIC_ANDROID_GOOGLE_SERVICES_FILE,
4943
intentFilters: [

src/screens/chat-screen/components/message-components/CommandOptionsMenu.tsx

Lines changed: 30 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -16,95 +16,39 @@ import { MAXIMUM_FILE_UPLOAD_SIZE } from '@/constants';
1616
import i18n from '@/i18n';
1717
import { showToast } from '@/utils/toastUtils';
1818
import { findFileSize } from '@/utils/fileUtils';
19-
import { getApiLevel } from 'react-native-device-info';
2019

2120
export const handleOpenPhotosLibrary = async dispatch => {
22-
if (Platform.OS === 'ios') {
23-
request(
24-
Platform.OS === 'ios'
25-
? PERMISSIONS.IOS.PHOTO_LIBRARY
26-
: PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE,
27-
).then(async result => {
28-
if (RESULTS.BLOCKED === result) {
29-
Alert.alert(
30-
'Permission Denied',
31-
'The permission to access the photo library has been denied and cannot be requested again. Please enable it in your device settings if you wish to access photos from your library.',
32-
[
33-
{
34-
text: 'Cancel',
35-
style: 'cancel',
36-
},
37-
{
38-
text: 'Open Settings',
39-
onPress: () => {
40-
// Open app settings
41-
Linking.openSettings();
42-
},
43-
},
44-
],
45-
{ cancelable: false },
46-
);
47-
}
48-
if (result === RESULTS.GRANTED || result === RESULTS.LIMITED) {
49-
const pickedAssets = await launchImageLibrary({
50-
quality: 1,
51-
selectionLimit: 4,
52-
mediaType: 'mixed',
53-
presentationStyle: 'formSheet',
54-
});
55-
if (pickedAssets.didCancel) {
56-
} else if (pickedAssets.errorCode) {
57-
} else {
58-
if (pickedAssets.assets && pickedAssets.assets?.length > 0) {
59-
validateFileAndSetAttachments(dispatch, pickedAssets.assets[0]);
60-
}
61-
}
62-
}
63-
});
21+
const pickedAssets = await launchImageLibrary({
22+
quality: 1,
23+
selectionLimit: 4,
24+
mediaType: 'mixed',
25+
presentationStyle: 'formSheet',
26+
});
27+
if (pickedAssets.didCancel) {
28+
} else if (pickedAssets.errorCode) {
29+
Alert.alert(
30+
'Permission Denied',
31+
pickedAssets.errorMessage ||
32+
'The permission to access the photo library has been denied and cannot be requested again. Please enable it in your device settings if you wish to access photos from your library.',
33+
[
34+
{
35+
text: 'Cancel',
36+
style: 'cancel',
37+
},
38+
{
39+
text: 'Open Settings',
40+
onPress: () => {
41+
// Open app settings
42+
Linking.openSettings();
43+
},
44+
},
45+
],
46+
{ cancelable: false },
47+
);
6448
} else {
65-
const apiLevel = await getApiLevel();
66-
const permission =
67-
apiLevel >= 33
68-
? PERMISSIONS.ANDROID.READ_MEDIA_IMAGES
69-
: PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE;
70-
71-
request(permission).then(async result => {
72-
if (RESULTS.BLOCKED === result) {
73-
Alert.alert(
74-
'Permission Denied',
75-
'The permission to access the photo library has been denied and cannot be requested again. Please enable it in your device settings if you wish to access photos from your library.',
76-
[
77-
{
78-
text: 'Cancel',
79-
style: 'cancel',
80-
},
81-
{
82-
text: 'Open Settings',
83-
onPress: () => {
84-
// Open app settings
85-
Linking.openSettings();
86-
},
87-
},
88-
],
89-
{ cancelable: false },
90-
);
91-
}
92-
if (result === RESULTS.GRANTED) {
93-
const pickedAssets = await launchImageLibrary({
94-
quality: 1,
95-
selectionLimit: 4,
96-
mediaType: 'mixed',
97-
presentationStyle: 'formSheet',
98-
});
99-
if (pickedAssets.didCancel) {
100-
} else if (pickedAssets.errorCode) {
101-
} else {
102-
if (pickedAssets.assets && pickedAssets.assets?.length > 0) {
103-
validateFileAndSetAttachments(dispatch, pickedAssets.assets[0]);
104-
}
105-
}
106-
}
107-
});
49+
if (pickedAssets.assets && pickedAssets.assets?.length > 0) {
50+
validateFileAndSetAttachments(dispatch, pickedAssets.assets[0]);
51+
}
10852
}
10953
};
11054

0 commit comments

Comments
 (0)