Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Login persistance with Akavache

$
0
0

Hi All,

I'm trying to implement login persistance feature in my app with Akavache but so far without success.
I want to have it because I don't want user to login in every single time he starts an application.

So in my SignInViewModel I am doing smth like this:

`User u = await _userRepository.SignIn(uDTO);

            if(u != null)
            {
                await BlobCache.UserAccount.InsertObject("User", u);

                MessagingCenter.Send<User>(u, "Authorized");
            }`

This is working OK the object is saved but in my Application based class I am doing smth like this:

`protected override void OnStart ()
    {
        base.OnStart ();

        BlobCache.UserAccount.GetObject<User>("User")
                .Subscribe(x => _u = x, ex => Console.WriteLine("No Key!"));

        if (_u != null) 
        {
            MessagingCenter.Send<User>(_u, "Authorized");
        }
    }`

I don't know how to test it on emulator, so I decided to test it on Android device, but after sign in, close and start the application I am not signed in.
What am I doing wrong? How to debug this (when I close the app the debugger close too)
thx


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>