6

I have a SQL Server database and when there is insert in a table I want to notify the Android app.

For example, when order receives, I insert it into a SQL Server database. I also want user to get notification in my app about the order. The app is always open. I use web services to contact with database.

I don't want to request the table every 10 seconds or so. Is there any other way?

Dale K
  • 25,246
  • 15
  • 42
  • 71
Misha Akopov
  • 12,241
  • 27
  • 68
  • 82

1 Answers1

3

You can use Google Cloud messaging service, see how to set server here.

Example: if you are using PHP then while inserting or changing any data you can push to notify GCM to the given dives. or else you can set triggers in SQL and call system services to notify GCM.

Dale K
  • 25,246
  • 15
  • 42
  • 71
Vikas Rathod
  • 374
  • 2
  • 14
  • I am using IIS(Windows) server and MS SQL database. And inserting from other android application, does it make any difference ? Can you give me example for those ? – Misha Akopov Mar 07 '14 at 06:08
  • ok, to connect to database you use web services, i guess asp.net or c# your case: you send request of order from device to server and server do some processing and then server insert it into a database. so if you are using asp.net or c# see http://steveloper.com/android-google-cloud-messaging-and-asp-net/ or http://www.codeproject.com/Tips/434338/Android-GCM-Push-Notification – Vikas Rathod Mar 07 '14 at 06:21
  • let me tell you to get notification to device you need device id and the message you want to send. what ever service or scripting language you are using just send a http request to gcm server with the given parameter and it will send your message to the device. – Vikas Rathod Mar 07 '14 at 06:23