我想知道所连接设备的电话号码。 我尝试了expo-contacts和expo-device库,但无法获得我想要的信息。我该怎么办?
import * as Contacts from "expo-contacts";
import * as Device from "expo-device";
useEffect(() => {
(async () => {
const { status } = await Contacts.requestPermissionsAsync();
if (status === "granted") {
const { data } = await Contacts.getContactsAsync({
fields: [Contacts.Fields.PhoneNumbers],
});
if (data.length > 0) {
const contact = data[0];
console.log("contact", contact);
console.log(Device);
}
}
})();
}, []);
如果您要求在设备上激活电话号码,那么您可以使用“react-native-device-number”库。