如何通过Flutter以编程方式获取运行我的android应用的设备的电话号码?
我知道我们可以使用以下语法在android studio中轻松完成此操作:
TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
String mPhoneNumber = tMgr.getLine1Number();
但是,如何使用flutter做到这一点?
答案 0 :(得分:2)
由于Apple限制其iOS应用并禁止访问电话号码,因此没有跨平台解决方案。您唯一可以做的就是编写一个仅支持Android并返回电话号码的程序包。请参阅:
Programmatically get own phone number in iOS
Get the device's phone number programmatically
对于Android:
Programmatically obtain the phone number of the Android phone