In react native we would use the Linking library to make this possible. So in this tutorial we would check out how to open Open Phone Dialer on Android & iOS.
Note: the tutorial work perfectly fine on Android emulator and real device but not on iOS simulator.
Steps
1) Import StyleSheet, Text, View, TouchableOpacity, Linking and Platform component in your react native project’s App.js file.
2) Create a function named as dialCall() in your main class. This function is the backbone of our project. In this function we would first use the platform component to check the device is android or ios then if device is android then store the number value in phoneNumber variable. At last we would pass the phoneNumber variable in Lining component which would open this in our dial pad screen.
tel : Open the given number in android.
telprompt : Open the given number in iOS devices.
3) creating a button with Touchable opacity in render’s return block and call the dialCall function on button onPress event.
Below is the Complete source code for App.js file class.
That’s it for now.
If you liked this article, then please subscribe to my YouTube Channel for video tutorials.