-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPushSettingsViewController.xaml.cs
87 lines (76 loc) · 2.21 KB
/
PushSettingsViewController.xaml.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using AirshipDotNet;
namespace MauiSample;
public partial class PushSettingsViewController : ContentPage
{
public PushSettingsViewController()
{
InitializeComponent();
}
protected override void OnAppearing()
{
base.OnAppearing();
enabledPushSwitch.On = Airship.Instance.UserNotificationsEnabled;
channelId.Detail = Airship.Instance.ChannelId != null ? Airship.Instance.ChannelId : "";
UpdateNamedUser();
UpdateTagsCell();
}
void displayFeatures(object sender, EventArgs e)
{
Navigation.PushAsync(new FeaturesViewController());
}
void enablePush_OnChanged(object sender, EventArgs e)
{
Airship.Instance.UserNotificationsEnabled = enabledPushSwitch.On;
}
void CopyChannelID(object sender, EventArgs e)
{
if (Airship.Instance.ChannelId != null)
{
Clipboard.Default.SetTextAsync(Airship.Instance.ChannelId);
DisplayAlert("Alert", "Channel ID copied to clipboard!", "OK");
}
}
void AddNamedUser(object sender, EventArgs e)
{
if (namedUserLabel.Text == null)
{
Airship.Instance.ResetContact();
}
else
{
Airship.Instance.IdentifyContact(namedUserLabel.Text);
}
UpdateNamedUser();
DisplayAlert("Alert", "Named user added successufully", "OK");
}
void AddTag(object sender, EventArgs e)
{
string tagToAdd = tagLabel.Text;
Airship.Instance.EditDeviceTags()
.AddTags(new string[] { tagToAdd })
.Apply();
UpdateTagsCell();
}
void UpdateTagsCell()
{
tagLabel.Text = "";
IEnumerable<string> tags = Airship.Instance.Tags;
string str = "";
foreach (string tag in tags)
{
str = str + tag + "\n";
}
tagsList.Text = str;
}
void UpdateNamedUser()
{
namedUserLabel.Text = "";
Airship.Instance.GetNamedUser(namedUser =>
{
MainThread.BeginInvokeOnMainThread(() =>
{
namedUserLabel.Placeholder = namedUser != null ? namedUser : "named user";
});
});
}
}