Search code examples
androidxamarinxamarin.formsxamarin.android

Enabling phone permissions without alerting the user to enable during runtime in Xamarin forms


I want to enable phone permission by default for an Android application. On checking multiple posts I see that it is getting added up at runtime explicitly by user during installation. Can I avoid it and enable it by default?

image showing phone permission

I am adding the permission READ_PHONE_STATE in Android Manifest. But this doesn't enable it by default unless and until the user goes to the setting and enable it manually.


Solution

  • Permission needs to be requested from the user. If you try to use the feature without permission, it will crash the app. The permission needs to be in the manifest and you need to request permission from the user as well. There is no way to do it automatically.

    Side note: I believe this permission specifically is under higher scrutiny when submitted to the Play Store. The announcement they sent last year mentioned that you'll only be able to use this permission if you provide a valid reason such as making an alternative dialer app.