Search code examples
androidiosionic-frameworkpermissionscapacitor

IONIC Capacitor Remove the unnecessary permissions in iOS & Android


When I create a project using Ionic Capacitor, automatically both iOS (info.plist) and Android(AndroidManifes.xml) have some default permissions:

AndroidManifes.xml Permissions:

<!-- Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Camera, Photos, input file -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Geolocation API -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" />
<!-- Network API -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Navigator.getUserMedia -->
<!-- Video -->
<uses-permission android:name="android.permission.CAMERA" />
<!-- Audio -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>

Info.plist Permissions:

<key>NSCameraUsageDescription</key>
<string>To Take Photos and Video</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Always allow Geolocation?</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Allow Geolocation?</string>
<key>NSMicrophoneUsageDescription</key>
<string>To Record Audio With Video</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Store camera photos to camera</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>To Pick Photos from Library</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>

Let's say my app doesn't need Camera access, If I remove it from AndroidManifest.xml, my app builds successfully and is posted in PlayStore without that permission, but if I remove anything from Info.plist after uploading through xCode I get email notification that I should add that permission that I just removed.

What is the correct way to do this, should I change other files in iOS?


Solution

  • On iOS they are not permission, they are usage descriptions.

    Usage descriptions are an additional text explaining why your app needs a permission at the moment the app request it.

    Since Capacitor ships all the core plugins and some of them request permissions, Apple code scanner detects the code and warns you to make sure you didn't forget about them. It's just a warning, you shouldn't worry, but also, there is no harm if you leave them there.

    On Android on the other hand, you can remove the permissions you don't use.