On 03/23/2013 05:53 PM, Kumar McMillan wrote:
On Mar 23, 2013, at 9:14 AM, Gangadhar Nittala <[email protected]> wrote:

On Friday, March 22, 2013 9:12:20 PM UTC+5:30, Andrew Overholt wrote:
Hi,



Anybody knows how to get the phone number from the device?


Go to Settings and select Device Information.  The phone number should

be displayed at the top.  If you're asking about programmatically

determining it, I'd recommend looking at the JS code that does this.

Although I think Settings may have elevated privileges to do so.



HTH,



Andrew
You can take a look at this function in gaia that retrieves the phone number as 
part of the device-information

https://github.com/mozilla-b2g/gaia/blob/master/apps/settings/js/about.js


loadHardwareInfo: function about_loadHardwareInfo() {
    var mobileConnection = getMobileConnection();
    if (!mobileConnection)
      return;

    var info = mobileConnection.iccInfo;
    document.getElementById('deviceInfo-iccid').textContent = info.iccid;
    document.getElementById('deviceInfo-msisdn').textContent = info.msisdn;
I'm not sure exactly what you were trying to do with the phone number but keep 
in mind this value may have been tampered with by a user who has access to the 
device. For example, when we do carrier billing we do things like network 
header authorization (with the operator) to trust the MSISDN.

    var req = mobileConnection.sendMMI('*#06#');
    req.onsuccess = function getIMEI() {
      document.getElementById('deviceInfo-imei').textContent = req.result;
    };

hth
_______________________________________________
dev-webapps mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-webapps
_______________________________________________
dev-webapps mailing list
[email protected]
https://lists.mozilla

.org/listinfo/dev-webapps

Thanks you very much!
This code is just what I need.
I'm working in a lifestyle app for MNOs, and I need the phone number to confirm the user identity.

I added this code for trying:
    var mobileConnection = getMobileConnection();
    if (!mobileConnection)
      return;

    var info = mobileConnection.iccInfo;
    console.log("____________"+ info.iccid);
    console.log("____________"+ info.msisdn);

    var req = mobileConnection.sendMMI('*#06#');
    req.onsuccess = function getIMEI() {
      console.log("____________"+req.result);
    };

And it return this error:
E/GeckoConsole(669): [JavaScript Error: "ReferenceError: getMobileConnection is not defined"

Do I need to add anything at manifest? Do I need to import anything? What's wrong? Any idea? Besides that if I go to settings and select device information, at phone number does not appear, but the phone has a SIM card inside.
Could be related?

Thanks
Regards

Go to Settings and select Device Information

_______________________________________________
dev-webapps mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-webapps

Reply via email to