Get unique identifier (MAC address, UDID, etc…) in

2019-02-23 14:29发布

问题:

I'm trying to get the MAC address for the network adapter of the user's device in an Adobe AIR Application for Android and iOS (iPad 2).

In Android it works correctly, but in iOS it doesn't. This is the code I'm using:

var vNetworkInterfaces:Vector.<NetworkInterface> = NetworkInfo.networkInfo.findInterfaces();

for each (var networkInterface:NetworkInterface in vNetworkInterfaces) {
    trace(networkInterface.hardwareAddress);
}

This works in Android, but in iOS I get this when trying to run findInterfaces():

Error #1009: Cannot access a property or method of a null object reference.

So it seems networkInfo.findInterfaces() is not implemented in iOS. I tried getting the value of:

NetworkInfo.isSupported

And the value of that is true in Android but false in the iPad 2. So it seems NetworkInfo is not supported in iOS

Is there any other way in iOS to get a unique identifier for the device? (it doesn't have to be the MAC; I just want to uniquely identify the user's device)

回答1:

Actually there is a way to get the MAC Adress on iOS too ;) : Getting NetworkInfo from both Android and iOS.



回答2:

Create your own random UID and save it on the device.

Each time app starts, see if you have already generated and stored the UID so you won't overwrite it.