I developed an iPhone app. User need to log in to update their credentials. I'm using iOS Keychain feature to store the username and password. So, next time user launch the app user will be logged in. I would like to add remember me feature in my app. So, user will have an option to check the remember me or not.
My question is if the user don't want to remember his credentials, when I'm suppose to clear the keychain? How do I know if the app is closing/shutdown?
– applicationWillResignActive:
– applicationDidEnterBackground:
These two methods are called depending on the situation when the app enters background.(sleep button/phone call etc).
You can look it up in the docs.
https://developer.apple.com/library/IOs/#documentation/UIKit/Reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/UIApplicationDelegate
You meed to write the login credentials to application preferences.
(Here is how to read write to iPhone app preference)
http://knol.google.com/k/iphone-sdk-application-preferences#
Also here is how to read default preferences
http://www.redcodelabs.com/2009/07/read-iphone-preferences/
Related
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.
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
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
User downloads my iPhone app from the appStore link I provide from invite email. Is it possible to persist/cache the user-data say email Address and pre-fill when the app launched.
Thank you.
You can get all the data that Apple allows you to get, which is absolutely none - you can't get the user's email, you can't get his phone number, you can't get his UDID. No way to identify him. If you want anything from the user, he needs to enter it manually. If you think about it - it's actually a good thing. All your iphone information is completely secure and protected.
No, this can't be done. Your special link might take the user to the app store, but then that's it. The act of installing the app has nothing to do with your link anymore and no data can be passed to the freshly installed app.
Of course once the app is installed, if the user taps on a special link you provide, it could force your app to run and provide data to it.
Maybe you could provide a QR code the use can scan with your app the first time they run it. The QR code can contain the data you want. Of course the user may choose to not scan the code. Then again, the user can install your app without using your link to begin with.
I wanna check through my application whether any user is logged in to the app store or not. I am not sure whether apple provided any provision to check that. I guess store kit might help me but i am not sure.
You can't do that. StoreKit framework is only for providing in-app purchase functionality to your app. Not the status of user session with app store.
Here is my situation...
I want my password to be encrypted and at the same time I want it to be in iPhone settings (by adding resource and accessing it through NSUserDefaults), but i think NSUserDefaults saves the password or information in plane text and iPhone takes care of everything in its Settings app if there is any change or whatever.
How could I make sure that information that I see in the Settings is coming from and going back to Keychain but before that, Is it possible? If not any other way? May be writing encrypted file?
I DO NOT want settings to be in my app.
thank you
us
The Keychain service cannot be invoked from within Settings, you need to do this within your app. It is good practice to ask users for their password within your app in a login page or UIAlertView at least (like the App Store does).
From the user's point of view, they don't want to have to launch Settings, enter their password, and then launch your app to log in, they want to do it all in one place.
The iPhone app I'm writing has an option in the SETTING page: "ask for password when launching this app". (As a security measure.)
If the user types in the correct password... the app runs.
If the user types in the wrong password... the app needs to immediately exit.
There isn't any kind of "immediately exit this app" in any framework (that I can find).
What is the app-store legal way to do this?
http://developer.apple.com/library/ios/#qa/qa2008/qa1561.html
There is no API provided for gracefully terminating an iPhone application. Under the iPhone OS, the user presses the Home button to close applications. Should your application have conditions in which it cannot provide its intended function, the recommended approach is to display an alert for the user that indicates the nature of the problem and possible actions the user could take - turning on WiFi, enabling Location Services, etc. Allow the user to terminate the application at their own discretion.
Just display a screen that says "The password you entered is invalid." Not sure why you wouldn't allow them to try again, though - I'd find being made to relaunch the app each time I make a typo quite frustrating.
There is none. Applications are not supposed to exit. What you can do, however, is what an application I wrote that needed network access does: present a UIAlertView with no buttons so that the user is forced to quit the app (press the home screen button).
Just keep in mind that with iOS 4.0 and multitasking, you’ll have to give the user another opportunity to enter the password if the application is put into the background and then restarted.
You can use
exit(0);
although not recommended as explained by others.