4

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)

OMA
  • 3,442
  • 2
  • 32
  • 39

2 Answers2

3

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

Michael Dillon
  • 1,037
  • 6
  • 16
alan_langlois
  • 476
  • 1
  • 4
  • 10
  • I am trying to use the code that is given in the example you have posted. When I call (com.adobe.nativeExtensions.Networkinfo.NetworkInfo) `NetworkInfo.networkInfo.findInterfaces()` it says I am trying to call a Method on a null object, but When I actually test NetworkInfo.networkInfo, it says its not null. Yes, I am using the nativeExtensions NetworkInfo. – WORMSS Sep 10 '12 at 09:48
  • 2
    The link doesn't work anymore, but there's some info on using the native extension here: http://www.adobe.com/devnet/air/native-extensions-for-air/extensions/networkinfo.html – Pier Aug 06 '13 at 05:51
0

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.

Breign
  • 146
  • 8
  • Thanks for your answer. Yes, that's what I'm doing. Generating a random code seems to be the only option for now. – OMA Aug 15 '11 at 16:06
  • 1
    this might also be relevant: http://venturebeat.com/2011/08/23/ios-5-udid-privacy/ – Breign Aug 31 '11 at 17:34
  • But what if the user deletes the app from the ios device?, the UUID is deleted to. I need that when the user reinstall the app, the UUID be the same that the first time he install the app. – Evaristoyok Feb 23 '12 at 16:19
  • 1
    Regarding deleting UUID's (and any local stored data). If you store it with EncryptedLocalStore, it will persist through app updates or deleteions of the app. – Breign Apr 02 '12 at 17:14
  • @Breign Thought it persisted through uninstalls, as the docs say, but it doesn't for me on my Samsung Galaxy Blaze.. Android 4.0.4.. uninstall the app, the whole encryptedlocalstore is gone. – jfaron Feb 29 '16 at 01:59