Issue
I have an await statement await SecureStorage.GetAsync("RegisteredUserID");
, which stored the User Id, in the Xamarin Secure Storage. The SetAsynch
and GetAsynch
can be only used with await
in Asynch Function.
But, In my App, in App.xml.cs
file, there is an Synchronize Function, where I want to get the value from Secure Storage and use as the value for options.AgentName
.
It seems like the Global Variable is one of the Solution. How could I achieve this?
public static IHostBuilder BuildHost(Assembly platformSpecific = null) =>
XamarinHost.CreateDefaultBuilder<App>()
.ConfigureServices((_, services) =>
{
services.AddAriesFramework(builder => builder.RegisterEdgeAgent(
options: options =>
{
options.AgentName = "Mobile Holder";
// Code
});
UPDATE
public string UserId { get; private set; }
protected override async void OnStart()
{
UserId = await SecureStorage.GetAsync("RegisteredPIN");
}
Solution
create a public property in App
and set it's value in OnStart
public string UserId { get; private set; }
protected override async void OnStart()
{
UserId = await SecureStorage.GetAsync("RegisteredPIN");
}
then anywhere in your app you can access the value
((App)App.Current).UserId
Answered By - Jason
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.