0

I am working on a MVC-4 C# web Application. The Application is connected with two mobile apps built in Ionic framework. Currently i am in need to send push Notification's from my web application to mobile app's and also i want to show notifications on web app if any change happens in database. I am using SQL Server 2008 as database. I have searched alo't about this and found Signal-R and SQL Dependency as one option to monitor database and send notification to web application,but Signal-R cant send notifications to mobile app's. I am looking for something that i can use for both purpose. I heard a bit about Firebug ,if it could serve my purpose kindly guide me a bit about that.. Any Suggestion Regarding this would be highly appreciated.

2 Answers2

0

if you want to push notification in android then used 'FCM' to push Notification.

please find follow link to push notification. Hope it will be useful for you.

Click Here

  • thanks for replying. Actually i want to send notification to both Android and IOS applications,as i mentioned the Mobile applications are built in Ionic framework which is cross platform and supports both IOS and Android.. –  Sep 29 '17 at 06:25
  • If i use 'FCM' will it monitor my database changes ?? means how this will work with SQL dependency or is there anything else that i will use to get changes in database at run time. @Rajkumar Dorkhande –  Sep 29 '17 at 06:26
0
var serverKey = "YourKey";
var senderId = "xx000..";
var result = "-1";
var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://fcm.googleapis.com/fcm/send");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Headers.Add(string.Format("Authorization: key={0}", serverKey));
httpWebRequest.Headers.Add(string.Format("Sender: id={0}", senderId));
httpWebRequest.Method = "POST";

var payload = new
{
  notification = new
  {
    title = title ,
    body = body ,
    sound = "default"
  },
  data = new
  {
    photo = photo ,
    Id = Id 
  },
  to = Model.FirebaseToken
  priority = "high",
  content_available = true,
};

var serializer = new JavaScriptSerializer();
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
  string json = serializer.Serialize(payload);
  streamWriter.Write(json);
  streamWriter.Flush();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
  result = streamReader.ReadToEnd();
}
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
  • 1
    Your answer could be improved by adding more information on what the code does and how it helps the OP. – Tyler2P Jul 10 '23 at 08:56