Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Is there something like a unique device id?
-
Is there something like a unique device id?
Thanks.
-
No. Apple has removed the APIs for obtaining a unique device ID for privacy reasons (was often used for tracking purposes). Depending on your use case, there might be alternatives though (e.g. if the device's name would be enough for you to identify it among your other devices...).
-
Hmm, yes i think that would be enough. Can you point me to the app which can be used to obtain the name?
-
You could use the
platform
module for this. Quick example:import platform print platform.node()
-
Why not use
uuid
?import uuid print(uuid.getnode()) print(uuid.uuid1())
-
@ccc That'll essentially return a random number on iOS. The result may be the same when running this multiple times within the same session, but when you restart Pythonista, you'll get a different one.
-
@ccc From the
uuid.getnode()
docs:Get the hardware address as a 48-bit positive integer. The first time this runs, it may launch a separate program, which could be quite slow. If all attempts to obtain the hardware address fail, we choose a random 48-bit number with its eighth bit set to 1 as recommended in RFC 4122. “Hardware address” means the MAC address of a network interface, and on a machine with multiple network interfaces the MAC address of any one of them may be returned.
(on Unix systems, it usually launches
ifconfig
to determine the MAC address, which isn't possible on iOS, so it falls back to the random 48-bit number)