aliessmael / Unity-Contacts-List

Unity Contacts List is a unity3d plugin for Android and iOS devices that enable you to access to contacts. Retreive names, phone numbers, and even photos.
42 stars 20 forks source link

Does this support Unity 2021+? #32

Open khoa-nguyen opened 10 months ago

khoa-nguyen commented 10 months ago

I've noticed this project has not been updated in a while. Does anyone know if this is still supported in Unity 2021+?

I have tried downloading the project and running it, but crashes when trying to fetch the contacts list.

Testing on android, logcat prints out missing permissions so I went in and added them to the androidManifest. For example, adding the READ_PHONE_NUMBERS:

And then using a different project to handle calling these permissions at runtime:

async void RequestPermission()
{
    AndroidRuntimePermissions.Permission result = await AndroidRuntimePermissions.RequestPermissionAsync( "android.permission.READ_CONTACTS" );
    AndroidRuntimePermissions.Permission result2 = await AndroidRuntimePermissions.RequestPermissionAsync( "android.permission.READ_PHONE_NUMBERS" );

    if( result == AndroidRuntimePermissions.Permission.Granted &&
        result2 == AndroidRuntimePermissions.Permission.Granted)
    {
        Debug.Log( "We have permission to Read Contacts and phone number" );
        // DO STUFF 
                Contacts.LoadContactList( OnDone, OnLoadFailed );
    }
    else
    {
        Debug.Log( "Permission state: " + result + result2 );
    }
}

And logcat prints out Permission state: GrantedGranted

But these issues still show up: TelephonyPermissions: reportAccessDeniedToReadIdentifiers java.lang.SecurityException: getIccSerialNumber: The uid 10387 does not meet the requirements to access device identifiers.

The last lines to get printed out before the app closes down are: at com.aliessmael.contactslist.ContactList.LoadInformation_thread(ContactList.java:81) at com.aliessmael.contactslist.ContactList$1.run(ContactList.java:66) at java.lang.Thread.run(Thread.java:1012)

It seems the contact list is trying to run but not all (or enough) permissions have been granted.

I do hope we can get this up and running again. Searching several years later for Unity display phone contact list still shows very few results.

shpitsmedia commented 1 month ago

Hi @khoa-nguyen Did you find a solution?