简体   繁体   English

如何在访问时在文本字段中获取并插入用户的电话号码

[英]How to fetch and insert user's phone number in text field on visit

Goal: When the User view page, from mobile device, automatically insert his phone number in the input field, to make it easier to convert him in a lead. 目标:通过移动设备在用户查看页面上自动在输入字段中插入他的电话号码,以便更轻松地将他转换为潜在客户。

Of course there will be a privacy policy etc. 当然会有隐私政策等。

It will be a promo page, where you can get an 10% discount on Burger King if you'll leave a phone number. 这将是一个促销页面,如果您留下电话号码,即可在Burger King享受10%的折扣。 When it's already typed-in it's a lot easier i Think. 当我已经输入时,它会容易得多。

So, can we automatically insert mobile user's phone number in text field? 那么,我们可以在文本字段中自动插入移动用户的电话号码吗?

If we can, what language do we have to use. 如果可以,我们必须使用哪种语言。

Thanks a lot. 非常感谢。

Manifest

<uses-permission android:name="android.permission.READ_PHONE_STATE"/> 

Activity

TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
String mPhoneNumber = tMgr.getLine1Number();
textfield.text = CTSettingCopyMyPhoneNumber();

但首先导入CoreTelephony.framework

In short, it's not possible. 简而言之,这是不可能的。 Reason being is the same reason as to why you cannot access local files via a website. 原因与无法通过网站访问本地文件的原因相同。 It would be a huge security and privacy issue if the browser was automatically allowed to access the local filesystem without user input. 如果自动允许浏览器在没有用户输入的情况下访问本地文件系统,将是一个巨大的安全和隐私问题。

You can ease the burden of phone number input by having masked inputs on the website in question. 您可以通过屏蔽相关网站上的输入来减轻电话号码输入的负担。 This article goes into quite a lot of detail regarding how to deal with telephone numbers in JavaScript. 本文详细介绍了如何处理JavaScript中的电话号码。 However, this is probably as close as you can get unfortunately. 但是,不幸的是,这可能离您很近。

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM