TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
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:
<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);
//Console.WriteLine(response.Content);
}
}
}
Can any one guide me, Thank you in advance!!
Reply
Answers (
1
)
Authentication in ASP.NET MVC 5 application using ASP.NET id
How to get mac address & Serial Number who is access URL MVC