Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.99 KB | None | 0 0
  1. using Firebase;
  2. using System;
  3.  
  4. namespace TestPushNotification
  5. {
  6.     class Program
  7.     {
  8.         private static readonly PushNotification Notification = PushNotification.GetPushNotification();
  9.  
  10.         static void Main(string[] args)
  11.         {
  12.             Notification.Config.YOUR_FCM_SERVER_API_KEY = "AIzaSyAlGYEvGdTGOR1qSbJ1t35-DJbB7u0FMJ0";
  13.             Notification.Config.YOUR_FCM_SENDER_ID = "";
  14.  
  15.             SendNotification();
  16.  
  17.             SendCustomNotification();
  18.  
  19.             Console.ReadLine();
  20.         }
  21.  
  22.         public static void SendNotification()
  23.         {
  24.             string fcmDeviceId = "fqVLhCOtiz8:APA91bGEyCjgWkTFCdJVeIldTTAyUF2eu36zf0_rE9cCFlMn7-MiMviGKTcvGfIb0TKmWJKbDdJGbz4Qw3sQv5EG5GduDyM7uoddsTpYXjdYfAOt0Sv7NVLBoBIyB4_nPR0PkrR5LJYB";
  25.             string title = "Test Miky";
  26.             string message = "My Message";
  27.  
  28.             string sResponseFromServer = Notification.SendNotification(fcmDeviceId, title, message);
  29.             Console.WriteLine(sResponseFromServer);
  30.         }
  31.  
  32.         public static void SendCustomNotification()
  33.         {
  34.             string fcmDeviceId = "fqVLhCOtiz8:APA91bGEyCjgWkTFCdJVeIldTTAyUF2eu36zf0_rE9cCFlMn7-MiMviGKTcvGfIb0TKmWJKbDdJGbz4Qw3sQv5EG5GduDyM7uoddsTpYXjdYfAOt0Sv7NVLBoBIyB4_nPR0PkrR5LJYB";
  35.             string _title = "Test Miky";
  36.             string _message = "My Message";
  37.  
  38.             var data = new
  39.             {
  40.                 to = fcmDeviceId, // Uncoment this if you want to test for single device
  41.                 priority = "high",
  42.                 content_available = true,
  43.                 notification = new
  44.                 {
  45.                     title = _title,
  46.                     body = _message,
  47.                     //icon="myicon"
  48.                     badge = 1,
  49.                     sound = "default"
  50.                 }
  51.             };
  52.  
  53.             string sResponseFromServer = Notification.SendNotification(fcmDeviceId, data);
  54.             Console.WriteLine(sResponseFromServer);
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement