added fetch contact from real device icon

This commit is contained in:
Jaanu423
2025-09-19 12:26:57 +05:30
parent d4b638ce2f
commit 3b1dc58405
10 changed files with 382 additions and 26 deletions
+29
View File
@@ -0,0 +1,29 @@
import { PermissionsAndroid, Platform, NativeModules } from "react-native";
const { ContactsModule } = NativeModules;
async function fetchContacts() {
if (Platform.OS === "android") {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.READ_CONTACTS,
{
title: "Contacts Permission",
message: "This app would like to view your contacts.",
buttonPositive: "OK",
}
);
if (granted !== PermissionsAndroid.RESULTS.GRANTED) {
console.log("Contacts permission denied");
return;
}
}
try {
const contacts = await ContactsModule.getContacts();
console.log("Contacts:", contacts);
} catch (error) {
console.error("Error fetching contacts:", error);
}
}
export { fetchContacts };