private static void OnCurrentSnapshot(IDocumentSnapshot?snapshot) { Current = snapshot?.ToObject <DonorUser>(); CurrentUpdated?.Invoke(Current); if (previousUID != Current?.UID) { previousUID = Current?.UID; CurrentChanged?.Invoke(Current); CrossFirebasePushNotification.Current.UnsubscribeAll(); if (!(Current is null)) { CrossFirebasePushNotification.Current.Subscribe("Urgent_Project"); } } _ = DonationBundle.SetCurrentAsync(Current?.CurrentDonationBundle); if (!(Current is null) && ThemeEngine.SetTheme(Current.DesiredTheme)) { SecureStorage.SetAsync("ThemePreference", Current.DesiredTheme.ToString()); } var newTopics = Current?.DonatedProjectUIDs.Select(x => "Project_" + x) .Where(x => !CrossFirebasePushNotification.Current.SubscribedTopics.Contains(x)); if (newTopics?.Any() ?? false) { CrossFirebasePushNotification.Current.Subscribe(newTopics.ToArray()); } System.Diagnostics.Debug.WriteLine(string.Join(", ", CrossFirebasePushNotification.Current.SubscribedTopics)); }
public void Save() { Task.Run(async() => { await XamarinSecureStorage.SetAsync(Constants.USER_ID, JsonConvert.SerializeObject(tokens)); }); }
private SecureStorage() { Task.Run(async() => { string storage = await XamarinSecureStorage.GetAsync(Constants.USER_ID); tokens = new Dictionary <string, string>(); if (!string.IsNullOrEmpty(storage)) { JObject obj = JObject.Parse(storage); foreach (var token in obj) { tokens.Add(token.Key, token.Value.Value <string>()); } } }).Wait(); }
private static void OnCurrentSnapshot(IDocumentSnapshot?snapshot) { Current = snapshot?.ToObject <PartnerUser>(); CurrentUpdated?.Invoke(Current); if (Current?.UID != previousUID) { previousUID = Current?.UID; CurrentChanged?.Invoke(Current); } if (Current?.TeamConfirmed ?? false) { Team.SetCurrent(Current.TeamUID); } if (!(Current is null) && ThemeEngine.SetTheme(Current.DesiredTheme)) { SecureStorage.SetAsync("ThemePreference", Current.DesiredTheme.ToString()); } }
public void Clear() { tokens.Clear(); XamarinSecureStorage.Remove(Constants.USER_ID); }