briankabiro/react-native-get-sms-android

Remove `uses-permission` from AndroidManifest.xml

sulaysumaria opened this issue · 4 comments

Problem Statement:

I am using react-native-get-sms-android for reading sms only. Still my app asks permission for WRITE_SMS and SEND_SMS, even though I have not asked for that permission.

Cause:

The permission specified in the AndroidManifest.xml of this plugin.

Solution:

Remove the permissions from this plugin's AndroidManifest.xml and let developers add it to their app's Manifest so that there are no permissions required that the developer is not aware of.

Workaround:

Add this to your app's android/app/src/main/AndroidManifest.xml and it will remove unnecessary permission.

<uses-permission android:name="android.permission.WRITE_SMS" tools:node="remove" />
<uses-permission android:name="android.permission.SEND_SMS" tools:node="remove" />

Also add xmlns:tools to your manifest tag to work:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example">

Also change the README accordingly. As it guides to add permissions manually to AndroidManifest.xml, which is not actually required. It should be changed to add the specific permission that a specific function requires.

Seems like a reasonable idea. Why not propose a PR to match?

Sure thing. I am new to react-native, so was just going through on some blog posts on how to develop plugins for react-native so that I don't accidentally break any other things. I will create a PR as soon as I am ready with the change. Maybe within 24 hours.

Thanks @sulaysumaria. We'd both be happy to offer advice on this.