user1995781 user1995781 - 11 months ago 254
Android Question

Cordova / Phonegap get phone number of device (Android & iOS)

Is it possible to develop a hybrid mobile app using Phonegap / Cordova and access the device phone number for both Android and iOS?

Answer Source

iOS: You can retrieve the phone number using the CoreTelephony framework, you will need to add the following Entitlement: However apple might reject your app once you upload it to the AppStore. However, if you plan to distribute using the "Enterprise Distribution" plan, you should have no problem at all, see answers by Igor Fedorchuk and Dylan here, and another elaborated answer here.

Android: Yes, you could use this plugin, or write a cordova plugin that bridges the following code:

TelephonyManager tm = (TelephonyManager)appContext.getSystemService(Context.TELEPHONY_SERVICE);
String mPhoneNumber = tm.getLine1Number();

The required permission is android.permission.READ_PHONE_STATE"