Git Product home page Git Product logo

cordova-phone-call-trap's Introduction

Cordova PhoneCall Trap

It is a Apache Cordova plugin to simplify handling phone call status and events in Android devices.

Install

$ cordova plugin add io.gvox.plugin.phonecalltrap

Quick Example

PhoneCallTrap.onCall(function(state) {
    console.log("CHANGE STATE: " + state);

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

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

Supported platforms

  • Android 2.3.3 or higher

References

We have tried PhoneListener but it is only compatible with Phonegap 1.6 and does not work with new Apache Cordova versions. Also, its deployment isn't as easy as an Apache Cordova plugin should be. We are thankful for their work, though.

https://github.com/devgeeks/PhoneListener

License

Cordova PhoneCall Trap is released under the MIT License.

cordova-phone-call-trap's People

Contributors

perenecabuto avatar renanoliveira avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-phone-call-trap's Issues

onCall undefined

Hi guys im new at ionic and i install this plugin, i already import the module of js on app.component.ts, like this ```
`import {PhoneCallTrap} from 'io.gvox.plugin.phonecalltrap/www/PhoneCallTrap';

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  rootPage:any = HomePage;

  constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
    platform.ready().then(() => {

      PhoneCallTrap.onCall(function(result) {
             console.log("CHANGE STATE: " + result.state);
             console.log("CALLER ID: " + result.number); // only in ringing state

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

          });

      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      splashScreen.hide();
    });
  }
};`
but when i do ionic serve, my console give me an error: Uncaught (in promise): TypeError: Cannot read property 'onCall' of undefined
TypeError: Cannot read property 'onCall' of undefined
Can you help me?

PhoneCallTrap undefined

Getting PhoneCallTrap undefined on the window scope.
Using cordova 6.2
Ionic 2
Angular 2, typescript.

thanks.

Error Callback getting fired always

Hi I am using this Plugin in Ionic so in Angular 5.

Code Snippet -

registerPhoneCallListener() {
    console.log('Registering phone call trap.');
    PhoneCallTrap.onCall(function(state) {
      console.log("CHANGE STATE: " + state);
      
      alert('State Chnage Alert In Call Trap ' + state);
          switch (state) {
              case "RINGING":
                  console.log("Phone is ringing");
                  break;
              case "OFFHOOK":
                  console.log("Phone is off-hook");
                  break;
      
              case "IDLE":
                  console.log("Phone is idle");
                  break;
          }
      }, function() {
        console.error('Error during registering phone call trap.');
        alert('1. Alert In Call Trap');
      });

      PhoneCallTrap.errorCallback(
        function() {
          alert('Alert In Call Trap');
        }
      );
  }

With this run, getting following console logs. Alert is what i was trying, but did not work.
Console -

console.log: Registering phone call trap. 
[23:58:59]  console.log: WARNING: PhoneCallTrap errorCallback not implemented 
[23:59:00]  console.error: Error during registering phone call trap. 

Please help here.

Call record

Is it possible to record call conversations in ionic by using this plugin?

IOS not working

Hi, I tried implementing this to IOS and the call onCall function is only called once, after that other events are not being pushed to the function.

Dual sim issue

How can i know for which sim is call if i have dual sim android device?

I tried the same example and but I am unable to work this plugin

I used the same example provided

declare var PhoneCallTrap : any;
I have used the above declaration but still I am unsuccessful. Please help

Error: Uncaught (in promise): ReferenceError: PhoneCallTrap is not defined
ReferenceError: PhoneCallTrap is not defined
at http://localhost:8100/build/main.js:262:13
at t.invoke (http://localhost:8100/build/polyfills.js:3:14976)
at Object.onInvoke (http://localhost:8100/build/vendor.js:4982:33)
at t.invoke (http://localhost:8100/build/polyfills.js:3:14916)
at r.run (http://localhost:8100/build/polyfills.js:3:10143)
at http://localhost:8100/build/polyfills.js:3:20242
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15660)
at Object.onInvokeTask (http://localhost:8100/build/vendor.js:4973:33)
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15581)
at r.runTask (http://localhost:8100/build/polyfills.js:3:10834)
at c (http://localhost:8100/build/polyfills.js:3:19752)
at http://localhost:8100/build/polyfills.js:3:20273
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15660)
at Object.onInvokeTask (http://localhost:8100/build/vendor.js:4973:33)
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15581)
at r.runTask (http://localhost:8100/build/polyfills.js:3:10834)
at o (http://localhost:8100/build/polyfills.js:3:7894)
at e.invokeTask [as invoke] (http://localhost:8100/build/polyfills.js:3:16823)
at p (http://localhost:8100/build/polyfills.js:2:27648)
at HTMLDocument.v (http://localhost:8100/build/polyfills.js:2:27893)

I am using ionic 3.9.2

Incoming number sent to JS listener

It would be useful if instead of the state as a string on the JS listener you'll receive an object with two properties: state and incomingNumber.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.