Sathiyaraj
Sathiyaraj

Reputation: 343

How I get calling a phone number in Cordova platform?

Which plugin is supported to get calling number find out in Cordova.

Upvotes: 0

Views: 1298

Answers (1)

L Balsdon
L Balsdon

Reputation: 995

Edit

If you looking for the incoming call, this is not possible at all on iOS due the each app being sandboxed.

On Android you would need to create your own plugin or modify an existing one.

Here's one that listens for incoming calls:

https://github.com/devgeeks/PhoneListener

Original

Assuming you mean you want to get the phone number of the device, you can use this plugin.

https://github.com/pbakondy/cordova-plugin-sim/blob/master/README.md

Installation:

cordova plugin add cordova-plugin-sim

Sample Usage:

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
      window.plugins.sim.getSimInfo(successCallback, errorCallback);
}

function successCallback(result) {
      console.log(result);
}

function errorCallback(error) {
      console.log(error);
}

// Android only: check permission
function hasReadPermission() {

window.plugins.sim.hasReadPermission(successCallback, errorCallback);
}

// Android only: request permission
function requestReadPermission() {

    window.plugins.sim.requestReadPermission(successCallback, errorCallback);
}

Upvotes: 1

Related Questions