0

I"m new in Android development. I need to create some king of a server on android phone, that sends back data. I did some research and found that there is a push notification that 3rd party server (C#) can send notification to the android app, but I didn't found any answers if on that notification app can send back a response (data that I decide to send )

For example: I have a android app that listening for notification. Some 3rd party server sends notification via Google notification services (some command). My android app catches it, and sends a response in JSON format back to requested 3rd party server.

Is it possible.

Does push notification supports response data send back?

Thank you.

Ilya Vinokurov
  • 145
  • 2
  • 12

3 Answers3

0

You can make simple http requests (get, post.. etc) back to the server. Check out this answer: Make an HTTP request with android

Community
  • 1
  • 1
salrawaf
  • 349
  • 2
  • 8
  • Thank you, but let me clarify my question. I need the following to happen. 3rd party request sends question to android app > android app parses the request and immediately reply data back to server. From server point of view it should be request and response synchronously – Ilya Vinokurov Nov 18 '13 at 13:00
  • In that case you're probably looking for a realtime connection. Perhaps using sockets. Check this link for a list of solutions for server/client connections, many of which include android: http://www.leggetter.co.uk/real-time-web-technologies-guide – salrawaf Nov 18 '13 at 13:12
0

Yes you can do that. You should look into Google Cloud Messaging. It supports sending push notifications to host application and sending response back to any third party server. Here is a link for implementing a client side application with GCM integration. and Here is an implementation document for server side.

Sayed Jalil Hassan
  • 2,535
  • 7
  • 30
  • 42
  • I still confused, can I do it in same notification? I send notification app gets it and replies data, meanwhile server waits for response. – Ilya Vinokurov Nov 18 '13 at 13:02
  • Once you read the docs particularly the client and server docs, it will make sense. GCM assigns a unique id to every device. when you send a push to a particular device, a broadcastReceiver listens to it on the client side and you can do what ever you want in response inside an IntentService for that particular notification like sending something to your server. Your server doesn't need to wait for response. You should write a simple receiver using Http requests that receive data from client when ever the client sends it. – Sayed Jalil Hassan Nov 18 '13 at 13:54
0

There are two ways to implement what you want with GCM.

If you use the simpler HTTP connection to GCM server, your server sends an HTTP request to GCM server, which delivers the message to your device. Your device has to create its own connection to your server to send data back to the server.

If you use the new CCS (Cloud Connection Server) connection to GCM server, your server connects to GCM CCS server with XMPP protocol. Your server sends a message to the GCM server over that connection, and GCM delivers it to your device. Your device can use the same connection to send messages back to your server (using the send method of GoogleCloudMessaging class). These messages are called device to cloud messages.

Eran
  • 387,369
  • 54
  • 702
  • 768