Download
Documentation: https://assetstore.essentialkit.voxelbusters.com/
0:00 Welcome to Address Book CPNP2
0:18 Overview
0:34 Setup
1:05 Usage
The Address Book allows the user to access their contacts inside your game. This can be helpful in sharing your game.
IG_AddressBookService.cs
using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using VoxelBusters.CoreLibrary; using VoxelBusters.EssentialKit; public class IG_AddressBookService : MonoBehaviour { public static IG_AddressBookService instance; AddressBookContactsAccessStatus status; public IAddressBookContact[] allContacts; //IG_AddressBookService.instance.allContacts[index]; // Start is called before the first frame update void Start() { instance = this; } //IG_AddressBookService.instance.ReadContacts(); public void ReadContacts() { status = AddressBook.GetContactsAccessStatus(); if (status == AddressBookContactsAccessStatus.NotDetermined) { AddressBook.RequestContactsAccess(callback: OnRequestContactsAccessFinish); } if(status == AddressBookContactsAccessStatus.Authorized) { AddressBook.ReadContacts(OnReadContactsFinish); } } private void OnRequestContactsAccessFinish(AddressBookRequestContactsAccessResult result, Error error) { Debug.Log("Request for contacts access finished."); Debug.Log("Address book contacts access status: " + result.AccessStatus); if (result.AccessStatus == AddressBookContactsAccessStatus.Authorized) { AddressBook.ReadContacts(OnReadContactsFinish); } } private void OnReadContactsFinish(AddressBookReadContactsResult result, Error error) { if (error == null) { allContacts = result.Contacts; var contacts = result.Contacts; Debug.Log("Request to read contacts finished successfully."); Debug.Log("Total contacts fetched: " + contacts.Length); Debug.Log("Below are the contact details (capped to first 10 results only):"); for (int iter = 0; iter < contacts.Length && iter < 10; iter++) { Debug.Log(string.Format("[{0}]: {1}", iter, contacts[iter])); } } else { Debug.Log("Request to read contacts failed with error. Error: " + error); } } }