👻 Multiplatform Contacts is a straight forward library used to get Contacts in Android and iOS.
Add the following on your Manifest file:
<uses-permission android:name="android.permission.READ_CONTACTS" />
You can add a dependency inside the androidMain
or commonMain
source set:
commonMain.dependencies {
implementation("io.github.lilytreasure:multiplatformContacts:1.0.1")
}
var phoneNumber by remember { mutableStateOf("") }
val multiplatformContactsPicker = pickMultiplatformContacts(onResult = {number->
phoneNumber = number
})
Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
Button(onClick = {
multiplatformContactsPicker.launch()
}) {
Text("Load contacts")
}
Text(text = phoneNumber)
}