Reputation: 337
I'm trying to initiate an immediate phone call without the middleware dialog.
I've used the Linking.openUrl()
but it didn't work.
react-native-immediate-phone-call does that but it requires linking which isn't possible with expo
.
What can I do?
Upvotes: 3
Views: 9790
Reputation: 11
Try Connecting to your real device it's not responding because you're using a simulator ... hope this helps
Upvotes: 1
Reputation: 21
import {Linking, Platform } from 'react-native'
const onCallMobilePhone = async (phoneNumber: number) => {
if(Platform.OS === 'android') {
Linking.openURL(`tel:${phoneNumber}`);
return;
}
if(Platform.OS === 'ios') {
Linking.openURL(`telprompt:${phoneNumber}`)
return;
}
}
Upvotes: 0
Reputation: 121
You can use Linking
. Import that by import * as Linking from "expo-linking"
.
Then use openURL
function where you use as argument tel
instead http
.
Similar like:
Linking.openURL('tel:+12 XXX XXX XXX')
where X is any digit.
Hope that was helpful ;)
Upvotes: 12
Reputation: 41
use react native phone call which can be installed from npm,,visit https://snack.expo.dev/@aboutreact/example-to-call-from-app-in-react-native on how to use the library
Upvotes: 0
Reputation: 1555
import * as Linking from "expo-linking";
Then you can directly link to phone call like
Linking.openURL(`tel:${phoneNumber}`);
There are other schemes also mentioned in the docs like mailto etc
Upvotes: 3
Reputation: 242
Haven't ever felt the need to use expo, but Linking is mentioned in their docs and should work just fine.
You will probably need to test on a real device though, as I don't believe it will work in the iOS emulator. I do think it works on Android simulators, but I can't remember for sure.
Upvotes: -1
Reputation: 153
You will have to use a react native project without expo or eject expo to use this module, as it is a native module and expo in my opinion is basically for learning.
So you will have to use it in a react native project created without expo
Upvotes: -5