AutoLogin without firebase SWIFT3 IOS

0

I would like to know how I can save the user information and do not need to log in whenever I minimize or close the app without the use of firebase.

    
asked by anonymous 14.11.2017 / 15:27

1 answer

1

You can store information by UserDefauls

To use, you take the instance of UserDefauls from the application and perform get and set operations on that instance, such as below,

// pega a instância do UserDefaults do 
let defaults = UserDefaults.standard 

//Verifico se para a chave showedHowTo tem um valor verdadeiro, se tiver eu faço algo...
if defaults.bool(forKey: "showedHowTo") {
    //faz alguma ação que é necessária

} else {
    //faz alguma ação que é necessária

    //marca a chave showedHoTo como verdadeira, na próxima vez que eu pegar o valor para essa chave, estará indicando verdadeiro
    defaults.set(true, forKey: "showedHowTo")
}

More information about you can read straight from the Apple documentation , which brings methods to store String, int, float and etc ...

In your case, since they are user credential information, if you have any sensitive information that needs encryption, you would recommend saving in KeyChain, since UserDefauls does not encrypt the information.

To use KeyChain, I recommend the KeyChain-Swift library that contains Wrappers for you to use and is very similar to UserDefauls .

    
14.11.2017 / 18:25