CallPhone.js 671 B

1234567891011121314151617181920212223
  1. import {Alert, Linking} from "react-native";
  2. import {Toast} from "@ant-design/react-native";
  3. import SyncStorage from "sync-storage";
  4. const CallPhone = (phone, call_type='') => {
  5. /**
  6. * 拨打电话
  7. * @param {string} phone
  8. * @example
  9. * call('18888888888')
  10. */
  11. const url = `tel:${phone}`;
  12. Linking.canOpenURL(url).then(supported => {
  13. if (!supported) {
  14. return Alert.alert('提示', `您的设备不支持该功能,请手动拨打 ${phone}`, [
  15. {text: '确定'}
  16. ]);
  17. }
  18. return Linking.openURL(url);
  19. }).catch(err => Toast.info('拨号错误'))
  20. }
  21. export default CallPhone;