Mas

Mas

  • NA
  • 478
  • 71.9k

How to call the webmethod on button clickevent for firebase

May 13 2020 4:34 AM
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:
  1. <form id="form1" runat="server">  
  2. <div>  
  3. <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"></asp:ScriptManager>  
  4. <asp:Button ID="Buttonsend" runat="server" Text="Send" onclick="notification_push();" />  
  5. </div>  
  6. </form>  
CS code:
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using System.Web.Services;  
  6. using System.Web.UI;  
  7. using System.Web.UI.WebControls;  
  8. using RestSharp;  
  9. namespace pushnotification  
  10. {  
  11. public partial class notification : System.Web.UI.Page  
  12. {  
  13. protected void Page_Load(object sender, EventArgs e)  
  14. {  
  15. }  
  16. [WebMethod]  
  17. public void notification_push(string cToken )  
  18. {  
  19. var client = new RestClient("https://fcm.googleapis.com/fcm/send");  
  20. client.Timeout = -1;  
  21. var request = new RestRequest(Method.POST);  
  22. request.AddHeader("Content-Type""application/json");  
  23. request.AddHeader("Authorization""key=server key");  
  24. request.AddHeader("Content-Type""text/plain");  
  25. request.AddParameter("application/json,text/plain",  
  26. "{\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);  
  27. IRestResponse response = client.Execute(request);  
  28. //Console.WriteLine(response.Content);  
  29. }  
  30. }  
  31. }  
Can any one guide me, Thank you in advance!!

Answers (1)