morenoh149 / react-native-contacts

React Native Contacts
MIT License
1.65k stars 564 forks source link

Use ActivityCompat to check if permission is granted #741

Closed sergeich closed 3 months ago

sergeich commented 4 months ago

There was a crash on pre-6.0 Android devices context.checkSelfPermission() required API level 23

Caused by java.lang.NoSuchMethodError: No virtual method checkSelfPermission(Ljava/lang/String;)I in class Lcom/facebook/react/bridge/ReactApplicationContext; or its super classes
       at com.rt2zz.reactnativecontacts.ContactsManager.isPermissionGranted(ContactsManager.java:1221)
       at com.rt2zz.reactnativecontacts.ContactsManager.checkPermission(ContactsManager.java:1149)
       at java.lang.reflect.Method.invoke(Method.java)
       ...
morenoh149 commented 3 months ago

@sergeich should we support older versions of android?

sergeich commented 3 months ago

At least they're declared as supported :) build.gradle: def DEFAULT_MIN_SDK_VERSION = 21 (Android 5.0)

The same ActivityCompat is used to request permission, so old versions are already supported but partially ContactsManager.java: ActivityCompat.requestPermissions(

I haven't seen any other issues with old Android versions with this patch

morenoh149 commented 3 months ago

@sergeich ok lets merge it.