forked from xamarin/GoogleApisForiOSComponents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Additions.cs
43 lines (35 loc) · 1.08 KB
/
Additions.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
using System;
using System.Threading.Tasks;
using Foundation;
namespace Google.InstanceID
{
public partial class InstanceId
{
public Task<string> GetIDAsync ()
{
var tcsId = new TaskCompletionSource<string> ();
this.GetID ((identity, error) => {
if (error != null) {
tcsId.TrySetException (new NSErrorException (error));
} else {
tcsId.TrySetResult (identity);
}
});
return tcsId.Task;
}
public Task DeleteIDAsync ()
{
var tcsId = new TaskCompletionSource<object> ();
this.DeleteID (error => {
if (error != null && error.Code == 1)
return;
Console.WriteLine ("Delete ID Callback");
if (error != null)
tcsId.TrySetException (new NSErrorException (error));
else
tcsId.TrySetResult (null);
});
return tcsId.Task;
}
}
}