Making a Phone Call in Expo

#1

I’m just trying to initiate a phone call. I’ve checked the linking in the documentation. I initially started with this just to get some reaction and it sends back an unhandled promise rejection warning.

_handleCall = () => {
var str = this.state.event.evalPhone;
var phoneString = str.replace(/-/g, "");
console.log(phoneString);

Linking.openURL(`tel:${phoneString}`);

}

After some searching around I updated it to this but this doesn’t even return anything since it is handling the error.

_handleCall = () => {
var str = this.state.event.evalPhone;
var phoneString = str.replace(/-/g, "");
console.log(phoneString);
const url = `tel:${phoneString}`;

Linking.canOpenURL(url)
	.then((supported) => {
		if (supported) {
			return Linking.openURL(url)
				.catch(() => null);
		}
	});

}

How can I just test to see that it’s working? Should I just publish it and test it there? I apologize if this is something dumb I’m missing.

#2

Hi @ashsvendsen26 - what is the error message in the unhandled promise rejection warning?

If you’re on Android, you may want to upgrade to the latest Expo client, as we’ve recently fixed a bug which prevented this from working in SDK 27 projects: https://github.com/expo/expo/issues/1711

#3

Hi @esamelson -

I am currently just working on the IOS side. I’ll keep that in mind when I do android as well.

Here’s a picture of the warning screen that I get.

#4

Hi @ashsvendsen26 - have you tried this on a real device? It may be that the iOS simulator is unable to open tel: links – if I look at my iOS simulator there does not seem to be a Phone app, suggesting it is unable to simulate making phone calls.

closed #5

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.