Is there a "remember me" in the login?

Hi. I’m refer and coding below document with using flutter sdk.

But I faced that a new login is required every time the app is launched.

This is very inconvenient. Is there any kind of automatically login like a “remember me”?

Hey, this doesn’t seem to be well covered in the docs, but the default behavior for the SDK is to remember logged-in users. You can access the current user by calling app.currentUser. So your app could work something like this:

var user = app.currentUser;
if (user == null) {
  // when the login call is successful, app.currentUser will become user
  user = await app.logIn(Credentials.anonymous());
}

return user;

If you want to support multiple users in your app (similar to Netflix/Youtube), you can refer to this page in the docs for help.

3 Likes

hey @nirinchev, is this applicable for all SDKs and all Authorization methods?

I am building a SwiftUI App and implemented login with Email/Password, AppleID & Google. I did not configure anything in my app regarding realm more than

let myRealmApp = RealmSwift.App(id: "<my-app-id")

on the top level. However if i close the app on my phone and reopen, users have to log in again.

In my App i am testing both the currentUser as well as the loggedInState, only returns false:

        if myRealmApp.currentUser?.isLoggedIn != nil || myRealmApp.currentUser != nil {
            self.isLoggedIn = true
        } else {
            self.isLoggedIn = false
        }```

It if, yes. I’m not sure why you’re seeing this behavior, but it’s not by design. Can you share how you’re authenticating the user and can you confirm you’re not logging them out at some point?