-5

I am working on an app that would send little bits of information to and from another device running the same app, very similar to a messenger. Right now, while testing other aspects of the app, I'm just using text messages, but obviously that's a bad idea in the long run.

The process my app takes is:

  1. Phone A sends a request to Phone B
  2. Phone B does whatever processing it needs to do, based on the received data (done)
  3. Phone B sends a response to Phone A
  4. Phone A does whatever processing it need to do, or alerts the user (done)
  5. Possibly add the same features to send data to Phone B from a pc, but that's not important. It would only be used if possible based on the method the phones use.

I do have access to a server that someone suggested I could write an API on, but I'm not very familiar with that, and I want to make sure that users wouldn't have to re-enter any IP addresses or anything else to connect to the service.

Edit

Apparently my question wasn't clear enough. I want to know how to go about doing this. What service would I need to use, or what already exists that I can utilize?

Cody Harness
  • 1,116
  • 3
  • 18
  • 37
  • 2
    What exactly is your question? The first idea that comes to mind is using http requests (and mySQL databases) to send data to the server, and then phones can check the server for sent messages, but I'm not sure what you are asking. – TomTsagk Dec 03 '15 at 21:11
  • 1
    There is no question here. You just wrote down your idea. – OneCricketeer Dec 03 '15 at 21:12
  • My question is how do I go about doing it. If I were to use the idea @TomTsagk suggested then I could have A send a message to website.com and then it would go to B? How would the site know what to do when something is sent to it? – Cody Harness Dec 03 '15 at 21:23
  • 1
    The answer to this is pretty broad, but you'd need something like a REST API. And the site won't know what to do with the data. You have to implement the logic for that site/server yourself. – OneCricketeer Dec 03 '15 at 21:30

1 Answers1

1

The logic should go like this: A sends data to server (probably a php file like website.com/app.php) the 'app.php' file contains php code that takes data and saves them on a database using mySQL. B should be configured to check the database for new data every X interval. When it does it asks server for the data and the server responds.

I suggest you read some things about php and also this to connect to mysql with php. Also learn some mySQL from here.

TomTsagk
  • 1,474
  • 9
  • 23
  • Is there not a way to have the web server send the data to the phone? Based on the nature of the app it would have to be checking the site every minute. – Cody Harness Dec 03 '15 at 21:40
  • 1
    @CodyHarness It's not possible for the server to communicate with the device. Especially considering that your said app might run on multiple devices. The normal way is for the app to check to the server for new data. Checking every minute is nothing, there are apps that check every 10 seconds. Edit: in a way, when the device checks for new data on the database, it can obtain them, but the server cannot do that by itself, only when the device asks for the data it can obtain them. – TomTsagk Dec 03 '15 at 21:47
  • I feel like this is really impractical. What happens with apps that have a huge userbase? You would have a really slow system since only one user can access the database at a time. – Cody Harness Dec 04 '15 at 16:24
  • @CodyHarness The whole point of a server, is that it sits there and "serves" data to anyone who asks. Also it's up to you to configure the database in such a way that it doesn't take long to put the data in a database, and that multiple users can use it at the same time. I'm sorry that you don't like it, but what makes you think the server searching for a device would be a lighter thing to do? If you study mySQL and php you will see it's not that big of a deal. – TomTsagk Dec 04 '15 at 18:25