Search code examples
androidfluttergoogle-playmobile-application

Will the Play Store raise a red flag if the permission code is not written in the app?


I'm a beginner in development. I have to add a feature to allow users to select images from the internal storage.

I want to know if the permission asking code must be written to this feature. If I don't write it, will the playstore raise a red flag when the user installs the app?

Thanks


Solution

  • If you don't request the appropriate permission, the app won't be able to perform the request - it will just fail.

    You should ensure that you include the appropriate permissions in your manifest.

    I believe that if you use the image_picker plugin provided by flutter, it should already handle this for you (for android at least, iOS needs stuff added to the info.plist). This is generally the recommended way of selecting an image, rather than writing code to read files directly from storage.

    The plugin is automatically adding something like this to your manifest:

    <!-- Devices running Android 12L (API level 32) or lower  -->
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
    
    <!-- Devices running Android 13 (API level 33) or higher -->
    <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
    <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
    
    <!-- To handle the reselection within the app on Android 14 (API level 34) -->
    <uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />
    

    If you were to be using images from the storage directly, you'd need to do something like this:

    <-- Devices running Android 12L (API level 32) or lower -->
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <-- Devices running Android > 12 -->
    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
    

    and then request the appropriate permissions at runtime using something like permission_handler.

    However, on android > 12, the MANAGE_EXTERNAL_STORAGE permission is considered high-privilege, so you would need to justify why it is required to get the app released. And it's the kind of permission that doesn't give a simple popup but rather requires the user to toggle it on in the settings.