Skip to content

Instantly share code, notes, and snippets.

@alvareztech
Created October 17, 2020 20:56
Show Gist options
  • Save alvareztech/ccdd18eb9041afb9c343ee48625102c3 to your computer and use it in GitHub Desktop.
Save alvareztech/ccdd18eb9041afb9c343ee48625102c3 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using AGConnectAdmin;
using AGConnectAdmin.Messaging;
namespace ConsoleApp1
{
class Program
{
private const string TOKEN_ANDROID =
"AJDMI8D_ZsXRA_Bpx9OLZwGwAKF-HFPCAX8hoBYL4AgwIYb1uzGuTm8ffs8Xu5spcn0KUFtyv3z3Hz8PjIiayHskVQOy2naWeppz0XfxnZ9sClGbJbFvaAJVv7HCZPKuVQ";
static void Main(string[] args)
{
AGConnectApp.Create(new AppOptions()
{
ClientId = "103010861",
ClientSecret = "b2bf3771e681be1b57f19f5cbfa5f453affa3349bb605a85ab8e8a5f8f4821cb",
});
SendAndroidMessage();
//SendDataMessage();
}
public static void SendAndroidMessage()
{
var response = AGConnectMessaging.DefaultInstance.SendAsync(new Message()
{
Android = new AndroidConfig()
{
Notification = new AndroidNotification()
{
Title = "Notification from .NET",
Body = "Hello world!",
ClickAction = ClickAction.OpenApp()
}
},
Token = new List<string>() {TOKEN_ANDROID}
});
Console.WriteLine("Response: " + response.Result);
}
private static void SendDataMessage()
{
var response = AGConnectMessaging.DefaultInstance.SendAsync(new Message()
{
Data = "{'k1':'v1', 'k2':'v2'}",
Android = new AndroidConfig()
{
Urgency = UrgencyPriority.HIGH
},
Token = new List<string>() {TOKEN_ANDROID}
});
Console.WriteLine("Response: " + response.Result);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment