React-native-contacts: incompatible with Android 6.0 due to Runtime permissions

Created on 9 Aug 2016  路  8Comments  路  Source: morenoh149/react-native-contacts

Starting from APILevel 23 = android version 6, permissions such asREAD_CONTACTS will not be asked before install but at runtime. It looks like some code will need to be added to support this.
https://developer.android.com/training/permissions/requesting.html

@morenoh149 if this is not already in the plan I can write a PR as I need it since I rely so much on this module for my app.

The link above provide an example with exactly this permission:

// Here, thisActivity is the current activity
if (ContextCompat.checkSelfPermission(thisActivity,
                Manifest.permission.READ_CONTACTS)
        != PackageManager.PERMISSION_GRANTED) {

    // Should we show an explanation?
    if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
            Manifest.permission.READ_CONTACTS)) {

        // Show an expanation to the user *asynchronously* -- don't block
        // this thread waiting for the user's response! After the user
        // sees the explanation, try again to request the permission.

    } else {

        // No explanation needed, we can request the permission.

        ActivityCompat.requestPermissions(thisActivity,
                new String[]{Manifest.permission.READ_CONTACTS},
                MY_PERMISSIONS_REQUEST_READ_CONTACTS);

        // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
        // app-defined int constant. The callback method gets the
        // result of the request.
    }
}

and

@Override
public void onRequestPermissionsResult(int requestCode,
        String permissions[], int[] grantResults) {
    switch (requestCode) {
        case MY_PERMISSIONS_REQUEST_READ_CONTACTS: {
            // If request is cancelled, the result arrays are empty.
            if (grantResults.length > 0
                && grantResults[0] == PackageManager.PERMISSION_GRANTED) {

                // permission was granted, yay! Do the
                // contacts-related task you need to do.

            } else {

                // permission denied, boo! Disable the
                // functionality that depends on this permission.
            }
            return;
        }

        // other 'case' lines to check for other
        // permissions this app might request
    }
}

At the moment this is what I got
screen shot 2016-08-09 at 10 00 31

a solution to this problem is also referenced here:
http://stackoverflow.com/questions/29915919/permission-denial-opening-provider-com-android-providers-contacts-contactsprovi

android

Most helpful comment

PR is welcome

All 8 comments

PR is welcome

@fabriziomoscon i'm running into the same issue. Can i help test perhaps?

I haven't started yet, I was planning to look at this in September. So please feel welcome to start the work and I will follow.

@fabriziomoscon any update on this?

Hi, unfortunately I am very busy on other components at the moment, which require 100% of my time. This is still in my radar, but I don't have an ETA for it.

@fabriziomoscon any progress on this yet?

Hi, sorry I didn't realise there were people relying on me for this.
Actually what I found out is that my app works on Android 6 even without this modification. So I prioritise this issue as nice to have.
But if someone could correct my observation and see that this change is actually needed I am happy to reconsider.

My app also works on android 6 without this change

Was this page helpful?
0 / 5 - 0 ratings