Autologin sem firebase SWIFT3 IOS

Asked

Viewed 43 times

0

I wanted to know how do I save the user information program and the same need not log in whenever minimize or close the app without using firebase.

1 answer

1

You can store information by Userdefauls

To use, you take the application’s Userdefauls instance 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 direct from apple documentation, which brings methods to store String, int, float and etc...

In your case, as they are information of the user’s credentials, in case you have some very sensitive information that requires encryption, I would recommend you save in Keychain, since Userdefauls does not encrypt the information.

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.