-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.xaml.cs
37 lines (28 loc) · 1.26 KB
/
App.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
using PushDemo.Models;
using PushDemo.Services;
namespace PushDemo
{
public partial class App : Application
{
public static string Hubsdroidtoken { get; internal set; }
public App()
{
InitializeComponent();
ServiceContainer.Register<IPushDemoNotificationActionService>(() => new PushDemoNotificationActionService());
ServiceContainer.Register<INotificationRegistrationService>(() => new NotificationRegistrationService(Config.BackendServiceEndpoint, Config.ApiKey));
ServiceContainer.Resolve<IPushDemoNotificationActionService>()
.ActionTriggered += NotificationActionTriggered;
MainPage = new MainPage();
}
protected override void OnStart() { }
protected override void OnSleep() { }
protected override void OnResume() { }
void NotificationActionTriggered(object sender, PushDemoAction e)
=> ShowActionAlert(e);
void ShowActionAlert(PushDemoAction action)
=> MainThread.BeginInvokeOnMainThread(()
=> MainPage?.DisplayAlert("PushDemo", $"{action} action received", "OK").ContinueWith((task)
=>
{ if (task.IsFaulted) throw task.Exception; }));
}
}