Use Xamarin.Forms.Application.Current.Properties in Firebase Messaging Service on Xamarin.Android

I am working on a Xamarin.Forms project. And used Firebase Cloud Messaging in Xamarin.Android Native Level.

I saved login details in Xamarin.Forms.Application.Current.Properties Dictionary.

After that, I used the same Xamarin.Forms.Application.Current.Properties in OnMessageReceived method of Service.

Now Xamarin.Forms.Application.Current.Properties Dictionary is accessible when App is in Foreground or in Background (But not killed). But, when App is closed/killed by swiping the App to left/right, Xamarin.Forms.Application.Current.Properties Dictionary is not accessible.

I tried to find out how Xamarin.Forms.Application.Current.Properties Dictionary can also be saved in Xamarin.Android SharedPreferences because it's accessible even the App is killed, but unable to succeed.

So, Can I achieve this? And if yes then How?


  • jezhjezh Member, Xamarin Team Xamurai

    You can try to use: SettingsPlugin ,

    This plugin saves specific properties directly to each platforms native settings APIs (NSUserDefaults, SharedPreferences, etc). This ensures the fastest, most secure, and reliable creation and editing settings per application. Additionally, it works with any Xamarin application, not just Xamarin.Forms.

    We can see from this link

    that you can save login information in SharedPreferences Of Android.

  • jezhjezh Member, Xamarin Team Xamurai

    Have you got your solution?
    The SettingsPlugin saves data with each platforms native settings APIs. On android ,it is actually SharedPreferences just as you need.

Sign In or Register to comment.