0

I am working on an SMS app with Cordova/Phonegap and I want to retrieve the user's SIM number on Android and iOS device for authentication and verification purpose.

Can someone please point me to a plugin or a blog on how to go about that, since i have spent almost a week searching and even trying to manipulate the device API, but still to no avail.

Thank you.

Sergi Juanola
  • 6,531
  • 8
  • 56
  • 93
David Addoteye
  • 1,587
  • 1
  • 19
  • 31
  • 1
    Please see [this post](http://www.learn-android-easily.com/2013/05/getting-imei-number-and-other-details.html) you may get some extra info on how to get info out of Android object TelephonyManager – Sunil Kumar May 26 '14 at 11:48
  • I found two plugins ready-to-use: https://github.com/pbakondy/cordova-plugin-sim and http://phonegap-plugins.com/plugins/rotorgames/phonegap-telephonenumber-plugin Or you can still create your own as in _Mark Smit_'s answer. – Erdal G. Nov 11 '15 at 12:15

1 Answers1

1

Impossible to do this in IOS:

Refer : Get the device's phone number programmatically

for android it should be easy to write such plugin yourself. you can get the number trough the telephony manager:

TelephonyManager tmanager;
tmanager= (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String number = tmanager.getLine1Number();
return fillPhoneNumber(number);

Howto make a plugin you can find here: http://docs.phonegap.com/en/2.0.0/guide_plugin-development_android_index.md.html

Community
  • 1
  • 1
Mark Smit
  • 582
  • 4
  • 12