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

onCall undefined #16

Open
kxylm opened this issue Jun 20, 2017 · 3 comments
Open

onCall undefined #16

kxylm opened this issue Jun 20, 2017 · 3 comments

Comments

@kxylm
Copy link

kxylm commented Jun 20, 2017

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?
@anil1712
Copy link

I am getting the same issue @kxylm did you get any solution on the same?

@abrahamadebayo
Copy link

Did you solve the issue @anil1712 ?

@arraintxo
Copy link

Check that your config.xml file has the next line:
<plugin name="io.gvox.plugin.phonecalltrap" spec="^0.1.2" />

Then on your component you don't need the import line, instead you have to declare the PhoneCallTrap variable:

declare var PhoneCallTrap: any;

@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();
    });
  }
}; 

I think that should 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

4 participants