Plugin for incomming/outgoing call

Hi,
Is it possible to attach to incomming/outgoing calls event with capicator? Maybe there’s some plugin for that? Or at least point me to a direction where to start?

After some research I found an unofficial Cordova plugin. I never used it so I can’t tell you if it works(the last update was 6 years ago). But you can try and see if it solves you problem

Yes! This is what I was looking for, thanks. The hardest part is to find right term for search. :grinning:

I’ll try it and report if it’s still working

1 Like

That plugin does work even though it’s very old. But I needed to receive phone number so I ended up using this one Cozzbie.

If anyone else would like to use this with quasar capacitor here are the steps:

cd src-capacitor
yarn add cozzbie.plugin.phonecalltrap
npx cap sync

Usage:
You can try

var PhoneCallTrap;

PhoneCallTrap.onCall(function(obj) {
    
    const callObj = JSON.parse(obj),
        state = callObj.state,
        callingNumber = callObj.incomingNumber;

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

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

Or


      function successCallback(call) {
        const callObj = JSON.parse(call)

    switch (callObj.state) {
        case "RINGING":
            console.log("Phone is ringing", callObj.incomingNumber);
            break;
        case "OFFHOOK":
            console.log("Phone is off-hook");
            break;

        case "IDLE":
            console.log("Phone is idle");
            break;
    }
      }
      function errorCallback() {
        console.log('error')
      }
      cordova.exec(successCallback, errorCallback, 'PhoneCallTrap', 'onCall', [])

I assume some permissions are needed but I’m unsure because I use it togheter with cordova-plugin-calllog which might have overlapping permissions.