Send push to Android by C# using Firebase and get response
you could save a response to database
and in the app could get a response from database.
The information will be in Database.
Sending Push Notification on Android Device using Firebase (FCM)
"invalid registration" indicates that the device token is incorrect, does not point to an existing device.
Mind that this does not mean a device that's turned off, it means that no device (currently) uses that token at all.
In other words it's an indication of a bad recipient address, effectively the equivalent of an HTTP 404 error.
C# FCM for Android Push Notification
I found the error. As a back-end developer I worked on C# part only. There is one more step to be done from mobile application side. Mobile app should allow receiving messages from list of Sender Ids so the one that I use in my C# code must be allowed from mobile app side. Once I did that it worked
Send In App Message to Android by C# .NET using Firebase In App Messaging
There currently is no API to configure the messages delivered/displayed by Firebase In-app Messaging. If this is a use-case you'd like to see added, I recommend you file a feature request.
The closest work-around at the moment would be to use Firebase Remote Config (which does have an API for setting configuration data) to deliver some value to your clients, and then have your clients display the message on those conditions. This is somewhat similar to what Firebase's In-app Messaging does behind the scenes, although (as far as I know) it uses its own infrastructure to deliver the configuration data.
FCM (Firebase Cloud Messaging) Push Notification with Asp.Net
C# Server Side Code For Firebase Cloud Messaging
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Web.Script.Serialization;
namespace Sch_WCFApplication
{
public class PushNotification
{
public PushNotification(Plobj obj)
{
try
{
var applicationID = "AIza---------4GcVJj4dI";
var senderId = "57-------55";
string deviceId = "euxqdp------ioIdL87abVL";
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.Message,
title = obj.TagMsg,
icon = "myicon"
}
};
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();
string str = sResponseFromServer;
}
}
}
}
}
catch (Exception ex)
{
string str = ex.Message;
}
}
}
}
APIKey and senderId , You get is here---------as follow(Below Images)
(go to your firebase App)
Related Topics
Passing a Vector/Array from Unmanaged C++ to C#
HTML Table (Text) to Image Using C#
Understanding Floating Point Problems
Does Java Have Something Similar to C# Properties
What Exactly Happens When I Set Loaduserprofile of Iis Pool
Best Way to Tackle Global Hotkey Processing in C#
Understanding Wcf Windows Authentication
Simultaneous Read-Write a File in C#
How to Create Deterministic Guids
How to Marshal a Struct That Contains a Variable-Sized Array to C#
How to Call an ASP.NET C# Method Using JavaScript
What's the Method Representation in Memory
C# Namespace Alias - What's the Point
Namespace' But Is Used Like a 'Type'
5.7.57 Smtp - Client Was Not Authenticated to Send Anonymous Mail During Mail from Error