Intelliwins Blog

Anything you wanna know about?

Send GCM notification from asp.net C# server

by Admin 2. November 2015 19:35
Google Cloud Messaging Alert From Asp.net C# Sending alerts via a Google Cloud Messaging service is one of the simplest and trickiest things to do in asp.net.  We have tried very simple methods in asp.net to successfully send notifications from server.    You need to know how GCM works. First of all you need to register with Google Cloud Messaging Service Where you need to provide the android app ID and details. Then it provides one API key and you also need the Project ID. You need both of these parameters while sending notifications. One more thing is require that is device id. When the GCM registered app is installed in the android device during registration process a device key and device id is created. We need both of these things while sending notification so that we can direct GCM to send notification for a particular device. We need to save this device ID in a database with our server. We need a web service by using which app developer can send device key and id. To send use the following c# method   public string SendNotification(string deviceId, string message) { string SERVER_API_KEY = "YOUR GCM API Key"; var SENDER_ID = "YOUR Project ID"; var value = message; WebRequest tRequest; tRequest = WebRequest.Create("https://android.googleapis.com/gcm/send"); tRequest.Method = "post"; tRequest.ContentType = " application/x-www-form-urlencoded;charset=UTF-8"; tRequest.Headers.Add(string.Format("Authorization: key={0}", SERVER_API_KEY)); tRequest.Headers.Add(string.Format("Sender: id={0}", SENDER_ID)); string postData = "collapse_key=score_update&time_to_live=108&delay_while_idle=1&data.message=" + value + "&data.time=" + System.DateTime.Now.ToString() + "&registration_id=" + deviceId + ""; Console.WriteLine(postData); Byte[] byteArray = Encoding.UTF8.GetBytes(postData); tRequest.ContentLength = byteArray.Length; Stream dataStream = tRequest.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); WebResponse tResponse = tRequest.GetResponse(); dataStream = tResponse.GetResponseStream() StreamReader tReader = new StreamReader(dataStream); String sResponseFromServer = tReader.ReadToEnd(); tReader.Close(); dataStream.Close(); tResponse.Close(); return sResponseFromServer; } Any Question Comment Below . Happy Coding !!! 

Tags: , , , , , ,

Android | Asp.net | GCM | Cloud Messaging

Android Secret Codes

by Admin 7. October 2013 19:21
These are few secret codes for android OS , This will help developers during testing android apps. Dial these codes in your phone and check. Phone Information, Usage and Battery – *#*#4636#*#* IMEI Number – *#06# Enter Service Menu On NewerPhones – *#0*# Detailed Camera Information –*#*#34971539#*#* Backup All Media Files –*#*#273282*255*663282*#*#* Wireless LAN Test –*#*#232339#*#* Enable Test Mode for Service –*#*#197328640#*#* Back-light Test – *#*#0842#*#* Test the Touchscreen –*#*#2664#*#* Vibration Test – *#*#0842#*#* FTA Software Version –*#*#1111#*#* Complete Software andHardware Info – *#12580*369# Diagnostic Configuration –*#9090# USB Logging Control –*#872564# System Dump Mode – *#9900# HSDPA/HSUPA Control Menu –*#301279# View Phone Lock Status –*#7465625# Reset the Data Partition toFactory State – *#*#7780#*#*

Tags: , ,

Tips and tricks | Android

Brit Colony, Bhubaneswar,India +91 94384 80191 info@ intelliwins.com

About Us

Intelliwins mission is to alter the dynamics of the software industry by providing trusted, supportive and quality software development servies to clients that view our partnership as a strategic driver for their success.

Newsletter

Enter your email to join our mailing list