Retrieve the UDID
Fellow developers,
I recently started out with Titanium and loving it so far. It enables me to build things much quicker (seeing how my ObjC skills are pretty much non-existent) but there's one thing I can't seem to figure out: how does one retrieve a device's UDID?
I know that, to be able to use the APNS implementation, one needs the UDID so Titanium must have a way to expose it, but so far, searching the docs has netted me nothing.
Any thoughts?
8 Answers
-
Accepted Answer
After letting this issue rest for a few days and revisiting it, my Google juice returned and I stumbled across this post from February 2010 outlining the correct way to retrieve the UDID:
Titanium.Platform.id
I tested it both in the Simulator and on my device and can confirm that it works for me.
-
You get it in iTunes. PLug your device in and then go to the device in iTunes.
Click on the serial number and it will switch to your UDID. Just hit Command/Ctrl+C and it'll copy to the clipboard.
-
Thanks for the quick attempt at answering. I know how to get my device's UDID from iTunes, but what I want to know is how to expose it programmatically from inside a Titanium based application.
-
Thanks Aubrey,
I've seen that code as well but am unable to print the UDID that way (tested in both the Simulator and on an actual device).
'UDID is: ' + Titanium.Network.remoteDeviceUUID,
simply echos: "UDID is: null".
Any other thoughts on how to get that kind of information?
-
Sorry, this code is for the 1.2 API
Titanium.Network.registerForPushNotifications({ types: [ Titanium.Network.NOTIFICATION_TYPE_BADGE, Titanium.Network.NOTIFICATION_TYPE_ALERT, Titanium.Network.NOTIFICATION_TYPE_SOUND ], success:function(e) { var deviceToken = e.deviceToken; label.text = "Device registered. Device token: nn"+deviceToken; Ti.API.info("Push notification device token is: "+deviceToken); Ti.API.info("Push notification types: "+Titanium.Network.remoteNotificationTypes); Ti.API.info("Push notification enabled: "+Titanium.Network.remoteNotificationsEnabled); }, error:function(e) { label.text = "Error during registration: "+e.error; }, callback:function(e) { // called when a push notification is received. alert("Received a push notificationnnPayload:nn"+JSON.stringify(e.data)); Titanium.Media.vibrate(); } });
-
Thank you again Aubrey. So am I right to assume that the only way to expose a device's UDID is by signing it up with an APNS?
It would seem like a very expensive way to get something that is available in ObjC very easily.
-
I agree - seems like a lot of code for just the UDID
(especially if you don't really want/need to use push notifications).If you figure this out… please post it here as I need to find a solution to this as well.
-
Titanium.Network.registerForPushNotifications({ types:[ Titanium.Network.NOTIFICATION_TYPE_BADGE, Titanium.Network.NOTIFICATION_TYPE_ALERT, Titanium.Network.NOTIFICATION_TYPE_SOUND ], // this function gives you a device token that must be sent to your server so // it can communicate with Apple's Push Service success:function(e) { Titanium.API.info("device token: "+e); //NOTE: this value is also available as the property Titanium.Network.remoteDeviceUUID }, // error callback error: function(e) { Titanium.API.info("push notifications disabled: "+e); }, // this function is called when you receive a push notification (either while running or at startup) // if you received a notification when you weren't running callback:function(e) { var a = Titanium.UI.createAlertDialog(); a.setMessage("callback: "+Titanium._JSON(e)); a.show(); } });