I have an application that has an android project, an iOS project, and a portable class library. I was wondering if there was a way I can store the code to provide session management inside of my portable class library. I'm also not sure where to set the
SecureStorageImplementation.StorageType = StorageTypes.PasswordProtectedFile
for sdk versions lesser than 26. I'm currently trying to implement this logic inside of my portable class library as a service that can be tested. The idea is to use the code in the portable class library for both iOS and android. I haven't been able to find any relatable examples in the samples you provided in the repo. This is my class implementation.
public class SessionService : ISessionService
{
/// <summary>
/// Method to retrieve an access token stored by <see cref="StoreSessionToken(SessionRequest)"/>
/// </summary>
/// <returns><see cref="SessionResponse"/></returns>
public SessionResponse RetrieveSessionToken()
{
var accessToken = CrossSecureStorage.Current.GetValue("AccessToken");
if (!string.IsNullOrWhiteSpace(accessToken))
{
return new SessionResponse() { Data = accessToken };
}
return new SessionResponse() { ErrorMessage = "Could not retrieve access token" };
}
/// <summary>
/// Stores an access token used to maintain a logged in users permissions.
/// </summary>
/// <param name="request"><see cref="SessionRequest"/></param>
/// <returns>bool in order indicate success.</returns>
public bool StoreSessionToken(SessionRequest request)
{
CrossSecureStorage.Current.SetValue("AccessToken", request.Data);
return CrossSecureStorage.Current.HasKey("AccessToken");
}
/// <summary>
/// Clears out the token used to store a session.
/// </summary>
/// <returns>bool in order to indicate success.</returns>
public bool ClearSessionToken()
{
CrossSecureStorage.Current.DeleteKey("AccessToken");
return CrossSecureStorage.Current.HasKey("AccessToken");
}
public void SetBackwardsCompatibleSettings()
{
//Plugin.SecureStorage.SecureStorageImplementation secureStorage = new Plugin.SecureStorage.SecureStorageImplementation();
//secureStorage .StorageType = Plugin.SecureStorage.StorageTypes.PasswordProtectedFile;
}
Hi,
I have an application that has an android project, an iOS project, and a portable class library. I was wondering if there was a way I can store the code to provide session management inside of my portable class library. I'm also not sure where to set the
SecureStorageImplementation.StorageType = StorageTypes.PasswordProtectedFile
for sdk versions lesser than 26. I'm currently trying to implement this logic inside of my portable class library as a service that can be tested. The idea is to use the code in the portable class library for both iOS and android. I haven't been able to find any relatable examples in the samples you provided in the repo. This is my class implementation.