How to use TelephonyManager tm = (TelephonyManager) in ionic


how to use TelephonyManager tm = (TelephonyManager) in ionic to get phone number in android

thank you.


You can use Cordova: org.apache.cordova.contacts.


i use it but give me error find in undefined


Like other plugins, it was define only on emulator and smartphone not on browser.


thank you for response, my problem i want anytime people connect from there phone i get phone number and i update my server with history. i did it before in java and i create my http in server, is working good. but in ionic i dont know how?

in java i use only this
TelephonyManager tm = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
String device_id = tm.getLine1Number();
wphone = device_id;

Thank you


Ok, this plugin is more suitable, if I understood:


so if i ask u but i use isnot working for me always give error devise is not definie


I have not yet had the opportunity to test this plugin, but Iā€™ll try to do it as soon as I have a moment.
Are these features suit you?


thank you for response, yes i create application with map google and i want to know anyone connect to app with his phone number.


I tested the plugin and it works, I put you a program excerpt to be tested.
Think about adding plugin
cordova plugin add

in Js file

.controller(ā€œExampleControllerā€, function($scope) {

$scope.telephony = function() {
    var deviceInfo = cordova.require("cordova/plugin/DeviceInformation");
    deviceInfo.get(function(result) {
        alert("result = " + result);
    }, function() {


in Index.html

<ion-pane ng-controller="ExampleController">
    <h1 class="title">Ionic</h1>
    <a class="button button-dark" ng-click="telephony()"> Telephony</a>


thank you for help but the problem is the same i did it, but give error that cordova.require not define

if you can zip for me complete example if you can.

thank you so much for your help.


You can fork this Project: [][1]

There is the APK in platforms/android/bin


Hey I was trying this out and I get an error ā€˜ReferenceError: cordova is not definedā€™.


Is there a place where I can read about how to properly install and use cordova plugins in my ionic project?


what r the steps to install this pluging for ionic ?


cordova plugin add


You can take a look at this tutorial:

> cordova plugin add


How to use phone state listener?


Can you explain that you want make exactly?


I created an app by using media plugin, I want to pause the media automatically while getting a call or message and resume to play it automatically after ending the callā€¦
can you suggest how we can achieve this