How to use TelephonyManager tm = (TelephonyManager) in ionic


#1

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

thank you.


#2

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


#3

i use it but give me error find in undefined


#4

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


#5

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


#6

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

https://github.com/vliesaputra/DeviceInformationPlugin


#7

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


#8

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?


#9

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


#10

I tested the plugin and it works, I put you a program excerpt to be tested.
Think about adding plugin
cordova plugin add https://github.com/vliesaputra/DeviceInformationPlugin

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() {
        alert("error");
    });
};

});

in Index.html

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

#11

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.


#12

You can fork this Project: [https://github.com/jimibi/TMApp][1]

There is the APK in platforms/android/bin
[1]: https://github.com/jimibi/TMApp


#13

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


#14

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


#15

what r the steps to install this pluging for ionic ?


#16

cordova plugin add https://github.com/vliesaputra/DeviceInformationPlugin


#17

You can take a look at this tutorial:

> cordova plugin add https://github.com/vliesaputra/DeviceInformationPlugin


#18

How to use phone state listener?


#19

Can you explain that you want make exactly?


#20

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