Hello,
Welcome to our Microsoft Q&A platform!
This Preferences.Set(App.UserID, App.UserID);
method means you save a value( App.UserID
) for a given key( App.UserID
) in preferences.
When you get the UserId
( var UserId = Preferences.Get(UserID, string.Empty);
) , the key is " UserID
"( public static string UserID = "UserID";
) . When you set the UserID
into preferences, you set App.UserID = auth.User.LocalId;
, the key is the value of auth.User.LocalId
not " UserID
", so the value is null.
You could replace the following code
App.UserID = auth.User.LocalId;
Preferences.Set(App.UserID, App.UserID);
to
App.UserID = auth.User.LocalId;
Preferences.Set("UserID", App.UserID);
or to
// App.UserID = auth.User.LocalId;
Preferences.Set(App.UserID, auth.User.LocalId);
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.