iOS App, How to set it to one time registration? - ios

I am Developing an App, that needs Registration, After launch Screen it shows Registration Screen. After Registration it allows to move on home Screen, and then any Task can be performed on the App.
Now I want my App to save the username and password into device, and on Launch, Application automatically registers the user.
if registration Successfully Achieved, then it automatically shows HomeScreen.
So my Question is, How do I achieve this?
I am beginner, Any Suggestion will be appreciated.
Thanks in Advance.

You should not to save password on your device. It's very not adviser to do that.
At the login, your API should return a session token. It is this one you have to save on device in Keychain. On launch, just retrieve the token in Keychain to be sure there is a session and go to HomeScreen, otherwise log out the user.
You can use this Lib https://github.com/matthewpalmer/Locksmith

You can use UserDefaults or Keychain.
https://developer.apple.com/reference/foundation/userdefaults
https://developer.apple.com/library/content/documentation/Security/Conceptual/keychainServConcepts/iPhoneTasks/iPhoneTasks.html

Related

check keychain is empty or not at start of app

I am building a password management app using objective c and it has two views, with sign up view being the initial/startup view and login view another.
Once the user registers with the app, i am saving the username and password in keychain.
I want to implement a functionality where, when the app launches, it checks if any user exist and if yes it should not show me sign up screen but instead show me login screen.
However i am not able to check wether keychain is empty or not when the app starts.
Please advice how can i do this functionality?

Storing log-in details for Xamarin iOS app

I am getting started with Xamarin iOS and writing an app that requires the user to log in, using their phone number (which can hopefully be pulled from the phone via API). What I would like is the first time they use the app, to see log in and sign up buttons. Sign up takes them through a storyboard to enter information which ends up saving their details in my server database so their account is now open. Log in will check if their phone number is registered and if so, sign them in to the app based on their phone number.
However if the app closes or the phone restarts, I would like them to be automatically logged in the next time they open the app, if they have previously created an account.
I am reading a lot of tutorials on sign up/login screens but none talk about how to have an "automatic" log-in option once they have authenticated, at least until they manually click the log out button. Lots of apps do this so Im sure it should be trivial, can anyone point me in the right direction? Do I have to store a value in the iOS file system or preferences folder structure? Maintain a local iOS DB with these settings?
iOS has a NSUserDefaults class that let's you store small bits of user configuration data in a persistent manner.
You can also use the iOS Keychain to securely store user credentials.

How Do I Force An iOS TouchID To Re-Authorize After Each Access, or Check If It is Unlocked?

OK. I suspect I just need to be directed to the appropriate "M" for "RTFM." I'm not new to iOS, but fairly new to keychain use. I am using a good keychain wrapper called "FXKeychain."
I have an app that includes a login, with a password stored in the default keychain.
I use TouchID to validate the user and fill in the password.
In order to do this, I display a "thumbprint" button, with an IBAction handler that runs the standard code:
self.s_authenticationContext.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: "Yo. Gimmie ur thumb.", reply: self.touchIDCallback)
The issue is, that once it is unlocked, subsequent touches of the button, using the above, skip the alert, and simply fall through.
This is an issue because the same button is displayed, even after the user is validated. I'd like to either:
Re-lock after entering the password, so the user must re-authenticate each time (preferred), or
Display a different button image that indicates the thumbprint is no longer necessary.
That means that I need to:
Find a way to re-lock the TouchID, or
Find out if the user is unlocked.
Any ideas?
Thanks!
It is your authentication context rather than the keychain that is 'unlocked'. If you allocate a new authentication context before calling evaluatePolicy then the touchID dialog will be shown again.
You can, however, actually use touchID to authenticate access to a keychain item directly. The Apple sample code demonstrates how to do this - https://developer.apple.com/library/ios/samplecode/KeychainTouchID/Introduction/Intro.html#//apple_ref/doc/uid/TP40014530-Intro-DontLinkElementID_2

iOS check user access token validity when app launches: best practice

I am currently developing an app which does have a user system. After user logins to the app, I will store user access token from the server and next time the app launches, the user will be auto logged in(or the login screen will be displayed if user is not logged, so the rootViewController will be set in applicaion didFinishLaunchingWithOptions).
So my question is what is the best practice for this? Currently what I have in mind is to set the root view controller to be some new controller(with in a spinner to indicate progress), and after the auto login(checking with server if the access token stored is still valid, if not valid, can be refreshed or not and stuff), I will manually set the rootViewController to be the correct one.
Someone also suggested me to hold the launch screen until the response from server is received.
thanks for your help.
Its may depends on the app security level. ie. Once the home page have no more secure details to display you don't have to hold at launch screen. but If you are developing a high secured app, Its must wait at launch screen until the responds is come from server for token check.

Swift - How to implement a login/session (no code)

My application has a login page and i would like to keep the user logged-in when he closes the app. Also, i have a logout button which should log-out the user and display the login page (even when he closes the app).
I tried to implement this using core data, but I have some issues with that and i'm not sure that is the best way to do it.
Can someone please give me some advices? I don't need code but just some idea of how i can implement that please.
Thanks!
You can make it as simple or complicated as you like. As simple as a Bool value in NSUserDefaults would do it. You could persist state in CoreData, Filesystem, NSUserDefaults. We store login credentials securely in the KeyChain.
For the authenticated areas of the app, check the state you have persisted on next app launch.
On logout, remove the state you have stored.

Resources