I'm doing an app for Android and I want to be able to send notifications from an asp.net server.
Since the Google Firebase console works correctly, you can send a notification to all devices that use the application.
As I have read it is not possible to send this type of notification from outside the console, so it has occurred to me that all the devices subscribe to a topic, and send the notification to the topic.
The problem is that I want to create the theme from the server, and I have no idea. I've tried this:
private void crearTopic()
{
try
{
var applicationID = "AAAARq_rfdY:APA92bH4GeOlB2p............";
string deviceId = "c9yessCNTc:APNN91bE................";//Mi movil
string url = @"https://iid.googleapis.com/iid/v1/"+ deviceId+"/rel/topics/minuevotema";
WebRequest tRequest = WebRequest.Create("url");
tRequest.Method = "post";
tRequest.ContentType = "application/json";
tRequest.Headers.Add(string.Format("Authorization: key={0}", applicationID));
using (Stream dataStream = tRequest.GetRequestStream())
{
using (WebResponse tResponse = tRequest.GetResponse())
{
using (Stream dataStreamResponse = tResponse.GetResponseStream())
{
using (StreamReader tReader = new StreamReader(dataStreamResponse))
{
String sResponseFromServer = tReader.ReadToEnd();
//Response.Write(sResponseFromServer);
string respuesta = sResponseFromServer;
}
}
}
}
}
catch (Exception ex)
{
string cad = ex.Message;
}
}
But an exception jumps, I suppose it's because of the ":" of the device ID.
Can someone help me out? or tell me some example page?
Thank you very much.