The react code works fine when running through an app, however, when running through a browser, it just opens a blank tab on iOS, on android it opens a tab where the url is the phone number.
Am I missing a critical piece of understanding of how React Native Web is used to build websites? How can I use react native to build a website where a button presents the device’s modal to call a phone number?
EDIT:: On Safari for ios, it opens another tab and then presents the user with the modal(this is good enough). On iOS, on Google Chrome, it opens and closes a tab and nothing happens. On Android, it opens a tab and nothing happens. Why the variation?
const callNumber = phone => {
// console.log('callNumber ----> ', phone);
let phoneNumber = phone;
if (Platform.OS !== 'android') {
phoneNumber = `telprompt:${phone}`;
}
else {
phoneNumber = `tel:${phone}`;
}
Linking.canOpenURL(phoneNumber)
.then(supported => {
if (!supported) {
Alert.alert('Phone number is not available');
} else {
return Linking.openURL(phoneNumber);
}
})
.catch(err => console.log(err));
};
2
Answers
I think you should segregate the platforms and then act on each platform like it needs. On the web, you should do the following: