-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMainPage.xaml.cs
More file actions
37 lines (31 loc) · 976 Bytes
/
MainPage.xaml.cs
File metadata and controls
37 lines (31 loc) · 976 Bytes
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 Plugin.Firebase.CloudMessaging;
namespace FirebaseCloudMessagingTutorial
{
public partial class MainPage : ContentPage
{
int count = 0;
public MainPage()
{
InitializeComponent();
CrossFirebaseCloudMessaging.Current.Error += (s, p) =>
{
if (p == null)
return;
Console.WriteLine($"PushNotification.Error, Message = {p.Message}");
};
}
private async void OnCounterClicked(object sender, EventArgs e)
{
try
{
await CrossFirebaseCloudMessaging.Current.CheckIfValidAsync();
var token = await CrossFirebaseCloudMessaging.Current.GetTokenAsync();
Console.WriteLine($"FCM token: {token}");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
}