I'm looking to uniquely identify an iPhone so our server can respond with some custom html. I want to be able to identify the phone in Safari and in an embedded browser in the app. Since each application is sandboxed, cookies won't work.
Thanks
A unique device identifier (UDID) is a 40-character string assigned to certain Apple devices including the iPhone, iPad, and iPod Touch. Each UDID character is a numeral or a letter of the alphabet. Using the UDID, third parties, particularly app vendors, can track subscriber behavior.
A unique identifier is a serial number, or string of characters, specific to a user's mobile device.
Basic Swift Code for iOS AppsEvery iOS Device has UDID which is a sequence of 40 letters and numbers that is guaranteed to be specific to your device. Device name is generally a name which will find in the device Setting→ General→ About. iOS Model describes whether the iOS device which user is using is an iPhone/iPad.
Use UUID UUID. randomUUID() method generates an unique identifier for a specific installation. You have just to store that value and your user will be identified at the next launch of your application.
This is not directly possible, but with the cooperation of the web site it is possible as Nick Lockwood has stated, and here's a greatly expanded version of the method he describes:
Your app should do this:
[[UIApplication sharedApplication] openURL:url];
http://yourwebsite.com/give-ios-app-the-cookie
your-app-url-scheme:cookievalue=<somevalue>
(eg. angrybirds:cookievalue=hh4523523sapdfa
)- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
process the url to get the cookie valueNote that you should not do this automatically when the application starts - the user will see the transfer to Mobile Safari and back, which is not a good user experience and Apple will reject your app (Apple also consider this to be "uploading user's personal data to server without their prior consent").
It would be better to do it in response to the user, paying attention to the user experience - eg. wait for the user to hit a "login" button, then do it, and if the user is not logged into your website, http://yourwebsite.com/give-ios-app-the-cookie should show the user the login screen within safari. If the user is logged in you could briefly show a "Automatically logging you in..." screen for a second or two in Safari before redirecting the user back.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With