I wonder why the debugging and release code branches are divided when checking Photo Library inside sendbird UIKit. In debug mode, only Photo Library permission is requested and the gallery can be opened, but in release mode, both Photo Library and Media Library (Apple Music) must be granted permission to operate. Ideally, I think the debug and release behaviors should be the same, but is there a reason for splitting these branches?
Below is the code.
@sendbird/uikit-react-native/src/plaform/createFileService.native.ts
const mediaLibraryPermissions: Permission[] = Platform.select({
ios: [permissionModule.PERMISSIONS.IOS.MEDIA_LIBRARY, permissionModule.PERMISSIONS.IOS.PHOTO_LIBRARY],
android: getAndroidStoragePermissionsByAPILevel(permissionModule),
default: [],
});
async hasMediaLibraryPermission(): Promise<boolean> {
const status = await permissionModule.checkMultiple(mediaLibraryPermissions);
if (
__DEV__ &&
Platform.OS === 'ios' &&
status['ios.permission.MEDIA_LIBRARY'] === 'unavailable' &&
status['ios.permission.PHOTO_LIBRARY'] === 'granted'
) {
return true;
}
return nativePermissionGranted(status);
}
@sendbird/uikit-react-native/src/utils/nativePermissionGranted.ts
import type { Permission, PermissionStatus } from 'react-native-permissions';
const nativePermissionGranted = (stats: Record<Permission, PermissionStatus>, limitedCallback?: () => void) => {
return Object.values(stats).every((result) => {
if (result === 'granted') return true;
if (result === 'limited') {
limitedCallback?.();
return true;
}
return false;
});
};
export default nativePermissionGranted;
I wonder why the branch processing is divided.