mugetsu
mugetsu

Reputation: 4398

how to get MAC address of phone with phonegap?

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

How would I do this?

Upvotes: 3

Views: 16091

Answers (5)

greaterKing
greaterKing

Reputation: 317

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

Upvotes: 2

Reign.85
Reign.85

Reputation: 2518

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

Upvotes: 2

Louis B.
Louis B.

Reputation: 2368

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+.

Upvotes: 5

greaterKing
greaterKing

Reputation: 317

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.

Upvotes: 1

Todd
Todd

Reputation: 31710

There's nothing in the API that would support this. Assuming you could get this information from Android or the iPhone, you'll need to write your own plugin to do it.

Upvotes: 0

Related Questions