hi,
i struggling use httpclient post fcm message. getting invald header format exception. can use webrequest post fcm message. want try async , await using httpclient.
please suggest me best httpclient or webrequest.
stringuri;
uri = "https://fcm.googleapis.com/fcm/send";
varpostdata = new
{
to = deviceid,
//to = togroup,
data = new
{
messageid = enquiryid
},
notification = new
{
body = enquirymessage,
title = fromuser,
icon = "myicon"
}
};
varserializer = newjavascriptserializer();
varjson = serializer.serialize(postdata);
using(varclient = newhttpclient())
{
client.defaultrequestheaders.authorization = newauthenticationheadervalue("key", "="+ fcmdetails.server_api_key);
client.defaultrequestheaders.accept.add(newmediatypewithqualityheadervalue("application/json"));
client.defaultrequestheaders.add("sender: id ", "="+ fcmdetails.project_key);
using(varr = awaitclient.postasjsonasync(newuri(uri), json))
{
stringresult = awaitr.content.readasstringasync();
sresponsefromserver= result;
}
}
hi,
firebase cloud messaging (fcm) java
http://bytefish.de/blog/fcmjava/ need work fcm support
firebase cloud messaging
https://firebase.google.com/docs/cloud-messaging/ hope helps.
--------------------------------------------------------------------------------------------
rob brown -
microsoft mvp <- profile - windows , devices it : bicycle - mark twain said right.
Community Participation Center / Discuss the Microsoft Community site / Getting started on Microsoft Community
Comments
Post a Comment