how to get MAC address of phone with phonegap?

15,860

Solution 1

You should consider using device.uuid, which returns an Universally Unique Identifier. It's probably the best way to uniquely identify a device and it works on almost any platform. Consult the PhoneGap API Docs for more information.

Update: It seems that this solution no longer works under iOS5+.

Solution 2

Yes as stated above the solution no longer works as desired. Though unique, the ID will change with each re-install of your app. What I was looking for was a way I could have a single constant unique identifier for the life of my app on the user device, regardless if they uninstall/install at least the ID will always be the same for that user. I found a secure solution here.

https://github.com/blackpixel/BPXLUUIDHandler

I ended up looking at the wizUtils plugin and with the help of a friend actually made it so I could use it as an actual plugin in phone-gap using it like one of the prebuilt wizUtils methods and it works!

Update 06/13/2019

For those using ionic4 check out (does the same thing)

https://ionicframework.com/docs/native/unique-device-id

Solution 3

https://github.com/mohamed-salah/MacAddress/tree/6869bad83906a760cb81bdc5e3c349e197cd215d

will work in 2.5.0, 2.7.0, 2.9.0, 3.0.0, 3.1.0, 3.2.0, 3.3.0

Solution 4

As Eskim0 pointed out, device.uuid won't return a persistent unique identifier because of changes to iOS. If the user uninstalls the app you will get a brand new identifier.

For most people trying to uniquely identify the device, the ID must be the same whether the app is uninstalled or not.

My thought were to get the MAC address sha256 with a nice salt on deviceReady and see if it exists in my database.

Share:
15,860
mugetsu
Author by

mugetsu

SOreadytohelp

Updated on June 28, 2022

Comments

  • mugetsu
    mugetsu almost 2 years

    Is it possible for me to obtain the MAC address of android and iphones via phonegap javascript?

    How would I do this?