0

May be it will be a too startup question.

We have developed an iPhone application and its uploaded in the Appstore. We have our own login mechanism, facabook login, and twitter login. Our users reporting an issue that, when the app is started and the iphone device is restarted (switched off), the application is also logged out. And users needs to login again. We have checked Facebook app. It keeps logged in when the device is restarted (switched off). We also want to do like that. Can you have suggest mechanism to do like that.

developerXXX
  • 689
  • 3
  • 7
  • 18
  • How about saving the login data? – rckoenes Mar 08 '13 at 14:45
  • How can we do that. Store the NSUserDefault to a file? – developerXXX Mar 08 '13 at 14:46
  • 1
    Yes you can, you can do what you like. But if you have something like a accesstoken or password then I would suggest using the KeyChain. – rckoenes Mar 08 '13 at 14:49
  • I guess you could save the access token (to the keychain as rckones suggests) and login (without user interaction) with it. You might want to check out the new (3.2) Facebook iOS SDK: https://developers.facebook.com/ios/features/whats-new-ios-sdk-3.2/ – Rok Jarc Mar 08 '13 at 14:56

2 Answers2

2

Store the Username and password in the keychain. When the app starts up, then grab the username and password from the keychain and execute the method for login.

John

John
  • 2,640
  • 1
  • 16
  • 16
  • When logging in with Facebook (i believe it's the same for Twitter) you don't have access to username and password. You could save access token though. – Rok Jarc Mar 08 '13 at 14:58
  • you're right I completely forgot that username/passwords are no longer used. But the pattern still works. – John Mar 08 '13 at 16:08
0

You can can Store your acessToken (facebook) with NSUserDefaults, CoreData or FileSystem. I will not suggest you to save your login/password inside your app. If you need to do this, its better save data user(name,address,celphone...) but not the access, like login/password. Its more safe. Of course, you can use KeyChain, but will each in what are you thinking doing with the app.

NSUserDefaults

Save string to the NSUserDefaults?

File System - apple guide

http://developer.apple.com/library/mac/#documentation/FileManagement/Conceptual/FileSystemProgrammingGUide/FileSystemOverview/FileSystemOverview.html

Core Data

Save and Load Data - CoreData

Community
  • 1
  • 1
  • You left out KeyChain - and it's most suitable to do the job. The hole purpose of KeyChain is to store account-related access data. – Rok Jarc Mar 08 '13 at 16:57