Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Callback getting fired always #23

Open
PrafullJoshi opened this issue Oct 24, 2018 · 7 comments
Open

Error Callback getting fired always #23

PrafullJoshi opened this issue Oct 24, 2018 · 7 comments

Comments

@PrafullJoshi
Copy link

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.

@zhaoxu666
Copy link

How to import this in Ionic4

@jstoppo
Copy link

jstoppo commented Jul 14, 2019

tried implementing this recently. It doesn't directly works on API level 29.
Change the code and permissions for android API level 29.

@PrafullJoshi
Copy link
Author

Yes, API level 29 has changed permissions model for call feature. not sure how to achieve this though.. will give a try and get back.

@nadimnakade
Copy link

How to import this in Ionic4

declare var PhoneCallTrap: any;
declare var window: any;

if (window.PhoneCallTrap) {
  window.PhoneCallTrap.onCall(function (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;
    }
  });
}

@alvinmactal
Copy link

Yes, API level 29 has changed permissions model for call feature. not sure how to achieve this though.. will give a try and get back.

Did you made this work?

@finansassistance
Copy link

no i couldnt achieve it

@alvinmactal
Copy link

no i couldnt achieve it

I recently upgraded my project from ionic 4 to 6, api level to 32 and used cordova android 12 and the plugin stopped working on my app. I'm still hopefull to make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants