-
Notifications
You must be signed in to change notification settings - Fork 1
/
ShhhSMSApplication.cs
53 lines (43 loc) · 1.42 KB
/
ShhhSMSApplication.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Threading.Tasks;
using Android.App;
using Android.Runtime;
namespace ShhhSMS
{
[Application]
public class ShhhSMSApplication : Application
{
public ShhhSMSApplication(IntPtr handle, JniHandleOwnership transfer) : base(handle, transfer)
{
}
public async override void OnCreate()
{
base.OnCreate();
await InitialiseDeviceId();
await InitialiseContactId();
}
private async Task InitialiseDeviceId()
{
var deviceId = await Xamarin.Essentials.SecureStorage.GetAsync(Constants.Identifiers.DeviceId);
if (deviceId == null)
{
deviceId = Guid.NewGuid().ToString();
await Xamarin.Essentials.SecureStorage.SetAsync(Constants.Identifiers.DeviceId, deviceId);
}
}
private async Task InitialiseContactId()
{
var contactId = await Xamarin.Essentials.SecureStorage.GetAsync(Constants.Identifiers.ContactId);
if (contactId == null)
{
contactId = Guid.NewGuid().ToString();
await Xamarin.Essentials.SecureStorage.SetAsync(Constants.Identifiers.ContactId, contactId);
}
}
public override void OnTerminate()
{
// TODO: Remove Password from Secure Storage
base.OnTerminate();
}
}
}