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
Guest User
Tech Writer
611
127.9k
Firebase push notification c#
Jun 22 2020 1:53 AM
var applicationID =
"dno8ujDPEuWJXrRzudDK"
;
var senderId =
"636408391381"
;
string
deviceId =
"*************"
;
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 = obj_Parameter.Message,
title = obj_Parameter.TagMsg,
icon =
"myicon"
},
priority =
"high"
};
var serializer =
new
JavaScriptSerializer();
var json = serializer.Serialize(data);
Byte[] byteArray = Encoding.UTF8.GetBytes(json);
tRequest.Headers.Add(
string
.Format(
"Authorization: key={0}"
, applicationID));
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();
obj.Response = 1;
obj.ErrorMessage = sResponseFromServer;
}
}
}
}
}
catch
(Exception ex)
{
obj.Response = 0;
obj.ErrorMessage =
"Internal Server Error"
;
}
return
obj;
I have test this code but i have face this error -
{\"multicast_id\":9049684377314331171,\"success\":0,\"failure\":1,\"canonical_ids\":0,\"results\":[{\"error\":\"InvalidRegistration\"}]}"
it's me parameter
{
"Message": "New Content!",
"TagMsg": "A new video has been uploaded."
}
Please solve this
Reply
Answers (
0
)
How generate random value fix range in C#
Delay response while converting Image?