CallPhone.js 817 B

12345678910111213141516171819202122232425262728
  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. try {
  19. const credential = SyncStorage.get('credential');
  20. } catch (e) {
  21. console.log(444444444, e)
  22. }
  23. return Linking.openURL(url);
  24. }).catch(err => Toast.info('拨号错误'))
  25. }
  26. export default CallPhone;