Eko Puji
Eko Puji

Reputation: 29

Missing permission android.permission.READ_PHONE_STATE on React - Native

I trying to build an app with react-native .. and i need to get imei from androidphone.. I added

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

on manifest.. But it still did not work, and the error appears on inspect element is...

Possible Unhandled Promise Rejection (id: 1): Error: Missing permission android.permission.READ_PHONE_STATE Error: Missing permission android.permission.READ_PHONE_STATE

i use RN version 0.61.2

Upvotes: 1

Views: 5440

Answers (2)

Ashad
Ashad

Reputation: 2513

The problem is that you had declared the permission and but user has not granted that permission

All permission in android are not same, some needs to be get access from user

You need to ask the user before accessing phone state and if the user deny it then you need to handle it

some reference may help you

Possible Unhandled Promise Rejection (id: 0): Error: Permission denied (while saving the image via "CameraRoll.saveToCameraRoll()")

Possible Unhandled Promise Rejection (id:0) Warning

Upvotes: 0

Waheed Akhter
Waheed Akhter

Reputation: 347

adding the permissions in the manifest file does necessarily give them to the app. Some permissions are considered dangerous and the user can disable them anytime starting from android marshmallow. So they have to be checked explicitly programmatically before using them. Read react native documentation for how to do that. https://facebook.github.io/react-native/docs/permissionsandroid

Upvotes: 2

Related Questions