0

I have the project in asp.net MVC 5 I need to add all option to my client-side app which is send a push notification to android and ios app for this scenario, I had created a page like a firebase cloud messaging => create message

firebase original page screenshot

c# code

    private static string SendPushNotification()
{
            string response;

            try
            {
            string serverKey = "##########"; 
            string senderId = "#############";
            string deviceId = "//topics/all";

            WebRequest tRequest = WebRequest.Create("https://fcm.googleapis.com/fcm/send");

            tRequest.Method = "post";
            tRequest.ContentType = "application/json";
            var data = new
            {
                to = deviceId,
                notification = new
                {
                    body = "Greetings",
                    title = "Augsburg",
                    sound = "Enabled"
                }
            };

            var serializer = new JavaScriptSerializer();
            var json = serializer.Serialize(data);
            Byte[] byteArray = Encoding.UTF8.GetBytes(json);
            tRequest.Headers.Add(string.Format("Authorization: key={0}", serverKey));
            tRequest.Headers.Add(string.Format("Sender: id={0}", senderId));
            tRequest.ContentLength = byteArray.Length;

            using (Stream dataStream = tRequest.GetRequestStream())
            {
                dataStream.Write(byteArray, 0, byteArray.Length);
                using (WebResponse tResponse = tRequest.GetResponse())
                {
                    using (Stream dataStreamResponse = tResponse.GetResponseStream())
                    {
                        using (StreamReader tReader = new StreamReader(dataStreamResponse))
                        {
                            String sResponseFromServer = tReader.ReadToEnd();
                            response = sResponseFromServer;
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            response = ex.Message;
        }

        return response;
}

So My query is that

1: I could send all these options to my HTTP request or not

2: There is open to send later open I need to also configure this option

3: And Target User option?

Could I do this using HTTP request by providing parameters?

Amit Singh Rawat
  • 559
  • 1
  • 9
  • 27

1 Answers1

1
  1. Not all.For most of the text fields, you can (see the docs for the HTTP ref):
    • Message Text = body
    • Message label: Nope. See the help text (?), it's just a label that the Firebase Console uses.
    • Delivery Date: See #2.
    • User Segment: See #3.
    • Message title = title
    • Android Notification Channel Name = android_channel_id
  2. Scheduled notifications are currently not available for the REST API.
  3. User Segments currently not available yet.
AL.
  • 36,815
  • 10
  • 142
  • 281
  • 1
    With all that said, please avoid asking multiple questions in a single post in the future. Cheers! – AL. Jun 08 '18 at 20:19