1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-05 23:53:33 +00:00
Files
mobile/src/Core/Services/AppIdService.cs
mpbw2 dbadf8c56f [PM-3222] Migration of data from LiteDB to shared pref storage (#2724)
* Migration of data from LiteDB to shared pref storage

* tweaks
2023-08-30 10:55:20 -04:00

34 lines
871 B
C#

using System;
using System.Threading.Tasks;
using Bit.Core.Abstractions;
namespace Bit.Core.Services
{
public class AppIdService : IAppIdService
{
private readonly IStorageService _storageService;
public AppIdService(IStorageService storageService)
{
_storageService = storageService;
}
public Task<string> GetAppIdAsync()
{
return MakeAndGetAppIdAsync(Constants.AppIdKey);
}
private async Task<string> MakeAndGetAppIdAsync(string key)
{
var existingId = await _storageService.GetAsync<string>(key);
if (existingId != null)
{
return existingId;
}
var guid = Guid.NewGuid().ToString();
await _storageService.SaveAsync(key, guid);
return guid;
}
}
}