This is my first post on here so be nice :) I am new to coding iOS and currently coding an app which uses a login system which communicates with the server and saves a users UDID. I need to app to check the UD开发者_开发问答ID is on the server and if it matches to auto fill the Username UITextField in the login form.
Please could someone help me out or point me in the right direction.
Mike
Welcome to SO.
I assume you know how to get the UDID? If not, you get it as this
NSString *udid = [[UIDevice currentDevice] uniqueIdentifier];
Send this to your server (where you have a table with UDIDs and corresponding user information). Using PHP (or whatever language you are using), check if there is an entry for this UDID on the server. If yes, get the corresponding username and set it in the text field as
[textField setText:theUserName];
If you don't know how to send requests and get response from iOS apps, ASIHTTPRequest would be a good and easy way to begin.
If you need any other specific help, I would suggest updating the question.
Welcome to both iOS and Stackoverflow!
You could build a PHP service which would verify the UDID of your device and check if this device and username are already registered at your site, asuming you are keeping track of these registrations using a MySQL database, PHP could most certainly do the trick.
After verifying the existence of this device, you could use a JSON callback to send the UDID of the device to the iPhone.
As for parsing this JSON check out SBJSONParser.
It might be hard to pull this off in 2 languages, asuming you are new to both. This task is possibly completed in more secure or easier methods, but this might be a consideration to check every part of web communication that the iPhone has to offer
Good luck!
Bryan
Mike, Apple will be phasing out UDID so you should really look at a new approach to this. I would suggest a combination of app.domain and the device MAC number.
Then, have your app talk to your server using HTTPRequest and return the data as JSON and parse that on the app side.
GitHub already has a solution to UIDevice uniqueidentifier being dropped: https://github.com/gekitz/UIDevice-with-UniqueIdentifier-for-iOS-5
Project Description:
Description
Apple stopped supporting a unique identifier for iOS. This source code solves the problem. It generates a unique identifier based on the mac address of the device in combination with the bundle identifier.
What you need to do:
copy NSString+MD5Addition and UIDevice+IdentifierAddition to your project.
use [[UIDevice currentDevice] uniqueDeviceIdentifier] to retrieve the unique identifier or
use [[UIDevice currentDevice] uniqueGlobalDeviceIdentifier] to retrieve a global unique identifier (used for tracking between different apps).
have fun and follow twitter.com/gekitz ;)
//Thanks to Erica Sadun for her UIDevice+Hardware Addition (used for the mac address retrieval).
精彩评论