1

I am looking for the best way to do a One Time Login for my iPhone application. Using iOS 5.1.1 SDK but targeting iOS 4.1 for deployment.

Its purpose is to fetch a generated ID: if an ID exists then I don't need to login anymore, the ID will be returned in XML.

My application is an extension to a current web based service, it involves asynchronous HTTP POSTs on location updates with an ID as an identifier and checking the XML returned for any errors. The ID does not expire. It is a single view application as it just requires a start/stop button.

The username for the web service never changes so I just want to fetch the ID once off, there is no benefit or security risk if a person was to hack things and get the id due to the nature of the service and the application providing no information on the user. The process I would like goes as follows.

  1. Application launched.
  2. Do we have an ID stored? (yes/no)
  3. If yes go into application.
  4. If no present username/password screen to get ID.
  5. On entering username/password, password is encrypted, sent to the server for verification, if yes then an id is returned and stored.

The username/password would be two inputs and a login button.

What would be the best way to go about this? I really don’t know what direction to follow here.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
sandmanza
  • 35
  • 4

2 Answers2

5

What I would recommend doing is using iOS's Keychain to store the ID of the user. You can never be too safe, Example usage can be found here GenericKeychain alternatively theres numerous easy to use wrappers to accomplish this.

If you really dont care for security, NSUserDefaults works for storage.

Also, I would suggest utilizing iCloud Document storage to make this ID persistent for all the user(s) devices. You can refer to this thread for more info.

Hope all that I suggested helped with your question !

UPDATE: For anyone else who finds this answer useful. As @sandmanza mentioned, be sure to include the Security.framework, if you go the Keychain route.

Community
  • 1
  • 1
skram
  • 5,314
  • 1
  • 22
  • 26
  • +1 For the iCloud suggestion and the Keychain **before** `NSUserDefaults`. – Rui Peres Jun 07 '12 at 08:23
  • Thanks, I want to do the application as properly as possible.Is there a wrapper you would reccomend ? – sandmanza Jun 07 '12 at 09:17
  • You can go here and follow the tutorial on how to use SFHFKeychainUtils, http://gorgando.com/blog/tag/sfhfkeychainutils if my suggestions suffice as the answer to your question please mark it off as such :) – skram Jun 07 '12 at 09:27
  • Thanks skram and Jacky Boy, got everything I need for this. – sandmanza Jun 07 '12 at 09:38
  • To those who get a bunch of errors please remember to add the security framework. – sandmanza Jun 08 '12 at 06:16
0

You can save ID in NSUserDefault and upon launching the app, you can retrieve ID from NSUserDefault and check whether ID is present or not, and based on that you can proceed further.

Nuzhat Zari
  • 3,398
  • 2
  • 24
  • 36