鸿蒙开发 拨打电话 API11

113 阅读1分钟
import call from '@ohos.telephony.call';

export class PhoneUtils {
  
  // 打开系统电话
 
  static async openUrlByTel(phone: string) {
    try {
      if (phone == null || phone == undefined || phone == "") {
        return "0";
      }
      await call.makeCall(phone).catch((err: BusinessError) => {
        Logger.error(TAG, `explicit start ability failed with ${err.code}`);
      })
      Logger.info(TAG, `explicit start ability succeed`);
      return "1";
    } catch (error) {
      Logger.error(TAG, `explicit start ability failed with ${error.code}`);
      return "0";
    }
  }

}