Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 562
user1995781 Avatar asked Aug 14 '15 08:08

user1995781


1 Answers

iOS: You can retrieve the phone number using the CoreTelephony framework, you will need to add the following Entitlement: com.apple.coretelephony.Identity.get. However apple might reject your app once you upload it to the AppStore.

But 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"

like image 176
Alon Amir Avatar answered Nov 15 '22 05:11

Alon Amir