-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathProgram.cs
41 lines (39 loc) · 1.41 KB
/
Program.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
using FirebaseAdmin;
using FirebaseAdmin.Messaging;
using Google.Apis.Auth.OAuth2;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
namespace FirebaseCloudMessaging.Example
{
class Program
{
static async Task Main(string[] args)
{
var defaultApp = FirebaseApp.Create(new AppOptions()
{
Credential = GoogleCredential.FromFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "key.json")),
});
Console.WriteLine(defaultApp.Name); // "[DEFAULT]"
var message = new Message()
{
Data = new Dictionary<string, string>()
{
["FirstName"] = "John",
["LastName"] = "Doe"
},
Notification = new Notification
{
Title = "Message Title",
Body = "Message Body"
},
//Token = "d3aLewjvTNw:APA91bE94LuGCqCSInwVaPuL1RoqWokeSLtwauyK-r0EmkPNeZmGavSG6ZgYQ4GRjp0NgOI1p-OAKORiNPHZe2IQWz5v1c3mwRE5s5WTv6_Pbhh58rY0yGEMQdDNEtPPZ_kJmqN5CaIc",
Topic = "news"
};
var messaging = FirebaseMessaging.DefaultInstance;
var result = await messaging.SendAsync(message);
Console.WriteLine(result); //projects/myapp/messages/2492588335721724324
}
}
}