如何使用 React Native 直接从应用程序拨打电话?

问题描述 投票:0回答:1

我尝试过

react-native-phone-call
,也尝试过在React Native中使用
Linking
,但这两种方法,首先打开提供号码的拨号器屏幕,然后我们必须手动按拨号器屏幕上的呼叫图标。

我希望呼叫应该直接从我的项目应用程序发起。它不应该打开拨号器应用程序然后拨打电话。

我想构建这样的东西,但在本机反应中:https://www.youtube.com/watch?v=UDwj5j4tBYg&t=19s

android react-native call
1个回答
0
投票

您可以使用链接打开拨打内容中的电话号码。

工作示例:https://snack.expo.dev/@msbot01/spunky-yellow-waffle

import { Text, SafeAreaView, StyleSheet, Button, Linking } from 'react-native';

export default function App() {
  return (
    <SafeAreaView style={styles.container}>
      
      <Button
        onPress={() => {Linking.openURL('tel:987323131');}}
        title="Call Helpline"
      />
      
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    backgroundColor: '#ecf0f1',
    padding: 8,
  }
});
© www.soinside.com 2019 - 2024. All rights reserved.