Hello members,
Hope you are doing good!!
Here i am trying to send the push notification using webmethod.
But it is not hitting on clickevent can anyone guide me.
ASPX:
- <form id="form1" runat="server">
- <div>
- <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"></asp:ScriptManager>
- <asp:Button ID="Buttonsend" runat="server" Text="Send" onclick="notification_push();" />
- </div>
- </form>
CS code:
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Services;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using RestSharp;
- namespace pushnotification
- {
- public partial class notification : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- [WebMethod]
- public void notification_push(string cToken )
- {
- var client = new RestClient("https://fcm.googleapis.com/fcm/send");
- client.Timeout = -1;
- var request = new RestRequest(Method.POST);
- request.AddHeader("Content-Type", "application/json");
- request.AddHeader("Authorization", "key=server key");
- request.AddHeader("Content-Type", "text/plain");
- request.AddParameter("application/json,text/plain",
- "{\n \"to\": \"****************\",\n \"priority\": \"high\",\n \"content_available\": true,\n \"notification\": {\n \"body\": \"Notify talpal\",\n \"title\": \"Talpal\",\n \"sound\": \"sound.caf\"\n }\n}", ParameterType.RequestBody);
- IRestResponse response = client.Execute(request);
-
- }
- }
- }
Can any one guide me, Thank you in advance!!