public async void OnMessageBroadcasted(object sender, BroadcastMessageEventArgs args) { Debug.Print("-----------in notificationbroadcasting message-------"); //RegisterId you got from Android Developer. String recieverId = "fo8m-sJVhSk:APA91bFd-bqtdW_j_6olexzPII4_KVxgIRtOWD2ZPCO900WjjyycfU3Gy7Q6-iUOeYQ3_Q-MmhgMEHvuZxEiImcr6bjVxqki-vhE_vJmRviM2xY3VsMYlAPckZ2lM0_Bh7zCnTnBWH4H"; string Google_App_ID = "AIzaSyBJG69jVZWgFt7ayf-FC3Wervecxfjm0Dg"; string Sender_ID = "AIzaSyBJG69jVZWgFt7ayf-FC3Wervecxfjm0Dg"; string title = "Demo Notification"; string tickerText = "Message Recieved"; string contentTitle = args.BroadcastMessage.Text; /*string postData = * "{ \"registration_ids\": [ \"" + recieverId + "\" ], " + * "\"data\": {\"tickerText\":\"" + tickerText + "\", " + * "\"contentTitle\":\"" + contentTitle + "\", " + * "\"message\": \"" + contentTitle + "\"}}";*/ var postData = new { to = "/topics/userBroadcast", priority = "high", content_available = true, notification = new { body = contentTitle, title = "Messages from HR", badge = 1, icon = "default", sound = "default" }, }; string postbody = JsonConvert.SerializeObject(postData).ToString(); string response = await SendGCMNotification(Google_App_ID, Sender_ID, postbody); }
void _chat_BroadcastMessageEvent(Vha.Net.Chat chat, BroadcastMessageEventArgs e) { // Dispatch message this.Write(MessageClass.BroadcastMessage, e.Message); }