如何在Ionic v4中检测呼入和呼出电话?

时间:2019-10-13 05:11:41

标签: typescript cordova ionic-framework ionic4 ionic-native

我想用ionic v4中的号码检测呼入和呼出电话。

我已经尝试过该插件(cordova-phone-call-trap https://github.com/renanoliveira/cordova-phone-call-trap),但无法正常工作。

phonecalls() {
  PhoneCallTrap.onCall(function (state) {
    //alert("CHANGE STATE: " + state);
    //var callObj = JSON.parse(state),
    ///state = callObj.state,
    console.log(state);
    this.callingNumber = state.number;
    //alert("callingNumber STATE: " + this.callingNumber);

    switch (state) {
      case "RINGING":
        console.log("Phone is ringing");
        this.callStatus = "Phone is ringing";
        break;
      case "OFFHOOK":
        console.log("Phone is off-hook");
        this.callStatus = "Phone is off-hook";
        break;

      case "IDLE":
        console.log("Phone is idle");
        this.callStatus = "Phone is idle";
        break;
    }
  });
}

0 个答案:

没有答案