react-native-sms
react-native-sms copied to clipboard
how to correctly handle permission?
I've got this error:
Fatal Exception: java.lang.SecurityException: Permission Denial: reading com.android.providers.telephony.SmsProvider uri content://sms/ from pid=23329, uid=10322 requires android.permission.READ_SMS, or grantUriPermission()
at android.os.Parcel.readException(Parcel.java:1620)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:421)
at android.content.ContentResolver.query(ContentResolver.java:502)
at android.content.ContentResolver.query(ContentResolver.java:445)
at com.tkporter.sendsms.SendSMSObserver.onChange(SendSMSObserver.java:99)
at android.database.ContentObserver.onChange(ContentObserver.java:130)
at android.database.ContentObserver.onChange(ContentObserver.java:145)
at android.database.ContentObserver$NotificationRunnable.run(ContentObserver.java:216)```
How should I handle this properly?
Hey @sibelius, have you tried adding <uses-permission android:name="android.permission.READ_SMS" />
to the AndroidManifest.xml? Found here
I have READ_SMS on my androidManifest
Maybe if this check fail https://github.com/tkporter/react-native-sms/blob/master/index.js#L9
we should no try to send a SMS
Yeah, I think you're right. When you run the app do you get a little alert asking for the READ_SMS permissions? I just got a new computer and don't have Android Studio set up, so it'd be great if you could submit a PR. It'd be great to keep it similar to the example in the docs: https://facebook.github.io/react-native/docs/permissionsandroid.html and maybe add a generic title and message like they did in the example
I think it is better to keep this package simpler
And let the user code handle permission
What do u think?
We can do a breaking change on semver and stop asking for permission