I'm trying to call (from https://firebase.google.com/docs/cloud-messaging/ios/device-group)
Retrieving a notification key
If you need to retrieve an existing notification key, use the notification_key_name in a GET request as shown:
https://fcm.googleapis.com/fcm/notification?notification_key_name=appUser-Chris
Content-Type:application/json Authorization:key=API_KEY
project_id:SENDER_ID
{}
Which looks like a GET with a message body and a content-type (!). If I POST it I get an error about missing notification_key_name. If I GET it using HttpClient It complains about it not being a JSON request and if I force it to have a Content-Type by doing:
_client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");
it gives me the same error. If I try and send a message body of "{}" with the GET request HttpClient refuses to send it.. Any ideas on how to get this to work?
I couldn't get HttpClient to do this, had to resort to using HttpWebRequest..
var wr = (HttpWebRequest)WebRequest.Create("https://fcm.googleapis.com/fcm/notification?notification_key_name=" + name);
wr.Method = "GET";
wr.ContentType = "application/json";
wr.Headers.Add("Authorization", "key=" + applicationID);
wr.Headers.Add("project_id", senderId);
var resp = await wr.GetResponseAsync();
using (Stream stream = resp.GetResponseStream())
{
StreamReader reader = new StreamReader(stream, Encoding.UTF8);
return reader.ReadToEnd();
}