简体   繁体   中英

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. 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. However, this is probably as close as you can get unfortunately.

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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