Cordova / Phonegap获取设备的电话号码(Android&iOS) [英] Cordova / Phonegap get phone number of device (Android & iOS)

查看:376
本文介绍了Cordova / Phonegap获取设备的电话号码(Android&iOS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用Phonegap / Cordova开发混合移动应用程序,并访问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?

推荐答案

iOS:
您可以使用CoreTelephony框架检索电话号码,您需要添加以下授权: com.apple.coretelephony.Identity.get
然而,一旦您的应用程序上传到AppStore,苹果可能会拒绝。
但是,如果您计划使用企业分发计划分发,您应该没有问题,请参阅Igor Fedorchuk和Dylan的回答此处,以及另一篇详细阐述的此处

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. 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:
是的,您可以使用此插件,或者编写一个cordova插件,桥接以下代码:

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();

所需的权限是 android.permission.READ_PHONE_STATE

这篇关于Cordova / Phonegap获取设备的电话号码(Android&iOS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆