Can someone help me how to send web download notifications to Firefox browser (desktop and mobile)?
To send a push notification to a Chrome browser, I use the following steps. 1) Create an application in FCM (to get the sender ID and api key) 2) Get the endpoints (registration IDs) using the javascript method shown in google docs. 3) Sending push notifications to all registration identifiers using asp.net C #. Below is the code
protected void SubmitButton1_Click(object sender, EventArgs e)
{
AndroidPush();
}
private void AndroidPush()
{
string regId = "APA91bG_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_V6hO2liMx-
eIGAbG2cR4DiIgm5Q ";
var applicationID = "AIzaSyDScBxxxxxxxxxxxxxxxxxxxpv66IfgA";
var SENDER_ID = "77xxxxx625";
var value = Text1.Text;
WebRequest tRequest;
tRequest = WebRequest.Create("https://android.googleapis.com/gcm/send");
tRequest.Method = "post";
tRequest.ContentType = " application/x-www-form-urlencoded;charset=UTF-8";
tRequest.Headers.Add(string.Format("Authorization: key={0}", applicationID));
tRequest.Headers.Add(string.Format("Sender: id={0}", SENDER_ID));
string postData = "collapse_key=score_update&time_to_live=108&delay_while_idle=1&data.message=" + value + "&data.time=" + System.DateTime.Now.ToString() + "®istration_id=" + regId + "";
Byte[] byteArray = Encoding.UTF8.GetBytes(postData);
tRequest.ContentLength = byteArray.Length;
Stream dataStream = tRequest.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse tResponse = tRequest.GetResponse();
dataStream = tResponse.GetResponseStream();
StreamReader tReader = new StreamReader(dataStream);
String sResponseFromServer = tReader.ReadToEnd();
Label3.Text = sResponseFromServer;
tReader.Close();
dataStream.Close();
tResponse.Close();
}
source
share