1

Is it possible to avoid that permissions as users are giving negative reviews on PlayStore on my app because of those permissions? I am using redux-persist to save user data in AsyncStorage.

Is there any way to avoid this without removing AsyncStorage?

jsartisan
  • 270
  • 4
  • 11
  • Why do you think that your app is asking for permissions because of `redux-persist` ? – Abdul Rauf Jun 25 '18 at 07:39
  • Because I am storing logged in user id in AsyncStorage using redux-persist. – jsartisan Jun 25 '18 at 08:35
  • AsyncStorage should work without any permission. See https://stackoverflow.com/a/46257815/2073920. I think your app is asking for permissions because of something else. What happens if you disable/remove redux-persist? – Abdul Rauf Jun 25 '18 at 09:45
  • 2
    https://medium.com/@jeevium/if-you-are-using-asyncstorage-react-native-api-you-need-these-2-permissions-7960b2e09022 Can you check this? I can't debug why its asking for those permissions. AsyncStorage seems to be culprit according to me. – jsartisan Jun 26 '18 at 13:30
  • That's strange. I have used asyncstorage in my app https://github.com/armujahid/reactnd-project-mobile-flashcards without using redux-persist and my app is not asking for any permissions and is working fine. I will upgrade it to use redux-persist and will post my response here – Abdul Rauf Jun 27 '18 at 14:38

2 Answers2

0

Accessing Photos/Files/Media is another thing which requires permission. But to use AsyncStorage (which redux-persist used) does not require any special permission it uses device storage.

refer this link docs.

Revansiddh
  • 2,932
  • 3
  • 19
  • 33
  • 2
    how is localStorage available in react-native? Am I missing something? As far as i know, localStorage is web api which is available in browsers. – jsartisan Jun 26 '18 at 13:28
  • localStorage is not available in react-native. AsyncStorage is the one available, mimicking the interface of localStorage/sessionStorage etc. In RN, AsyncStorage is a web API driving the native platform components that are performing the permanent device storage. – jeevium Jun 28 '18 at 20:21
  • local storage means device's storage, not in terms of one that browser – Revansiddh Jun 29 '18 at 04:55
0

If you are importing AsyncStorage to your React Native app, (import { AsyncStorage } from 'react-native'), RN will add on build time the following 2 permissions for Android application: READ_EXTERNAL_STORAGE & WRITE_EXTERNAL_STORAGE

If you configure Android Manifest to always remove these permissions on build time, the app will not work properly. I tried it with my app and it could not read the user's sessionId I was saving in AsyncStorage. So in reality, you cannot get rid of these permissions if you are using AsyncStorage.

If you are still in doubt about the permissions requested, you can always check the permissions listing of your app in Google Play. This is from my app that uses AsyncStorage:

enter image description here

Thanks to user @user2580324 for mentioning my article and to @Abdul Rauf for pointing out this thread to me.

jeevium
  • 733
  • 6
  • 10
  • so there is no alternative to save session data in the phone other than AsyncStorage? – jsartisan Jun 29 '18 at 04:21
  • I don't see another option currently. And even if there was Android permissions should still be required right? This is a nice [stack overflow answer](https://stackoverflow.com/questions/44376002/what-are-my-options-for-storing-data-when-using-react-native-ios-and-android) for storing options in RN – jeevium Jun 29 '18 at 09:25
  • Actually, you can interact directly with the filesystem with [this package](https://github.com/itinance/react-native-fs) – jeevium Jun 29 '18 at 17:37
  • Even if I try to access the filesystem, won't it ask for access of storage? – jsartisan Jul 03 '18 at 05:04
  • Most probably yes – jeevium Jul 04 '18 at 06:10
  • We all got it wrong @jeevium. Async Storage was not asking for any extra permission. The culprit was some other library. We can see manifest-merger-debug-report.txt file to check which library is asking for permissions other than defined in our AndroidManifest.xml file. **ADDED from [com.google.android.gms:play-services-analytics:11.0.4] /android/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-analytics/11.0.4/AndroidManifest.xml:24:22-65 190: android:uses-permission#android.permission.WRITE_EXTERNAL_STORAGE ** – jsartisan Jul 04 '18 at 07:21
  • To solve this, i added these lines in my AndroidManifest.xml – jsartisan Jul 04 '18 at 07:25
  • @jsartisan I have already tried this exact same approach a few months ago and it doesn't work - I will check the manifest-merger-debug-report.txt file as you say though. When I tried it, Ι uploaded signed APK to Google Play Beta; the Storage permissions were gone but my app could not read sessionId from AsyncStorage anymore, thus users re-opening the app could not login. – jeevium Jul 04 '18 at 12:10