How to sync an App with a Web Server

Hi guys, first of all let me tell you that Im with Swift for a year so maybe my questions are not advanced. I am trying to make my first App and I was wondering if someone could tell me how can I do if I need to sync my App with a Web Server. Although my App has nothing yet to be with this I just need to know how can it be accomplished with Swift.
Consider the following scenery. A newspaper that has it’s webpage and also needs an App. To synchronized with the web the App needs to speak with the web server or you just have to update the App every time a news is coming? I think this approach is not valid but on the other hand I just dont know how is it made.
Anyone that can help me?



If you have used something like AFNetworking in the past you might want to keep using it, but in Swift you don’t really need to look beyond URLSession. That’s the client side. The server side really determines what you have to do on the client side - it defines the interface that you must address. If the server exists already that’s a huge job you don’t have to do.

Another important consideration is how does your client get notified of changes? Will you poll (connect to the server periodically and check) or will you receive push notifications that trigger a fetch from your application to stay up to date?

If you are thinking of a newspaper app then a twitter-like model might work. Ever time your user opens the app then a server connection is made and the content is refreshed. This is reasonable considering most of what you will fetch is text and will not take long to get. Any images or other media can have a placeholder displayed until those assets are loaded, then the placeholder is replaced with the asset when it is completely received. It would be a good idea to get a tool like Paw or Charles and to examine the traffic that occurs between a simple app like twitter.

1 Like

@aeberbach Thank you very much for your quick response, it really helps a lot. What I need to do is the following. On one hand the web page is done by the web developer, not me. The Web is about cooking services and offers cook courses. I need to create an App that has the same photos but when courses change their price or the course dates, It has to be reflected too on the App.
That is my concerned on how to do that. Do I have to talk with the Web programmer?

Thanks a lot :slight_smile:

You will definitely need to have a good relationship with the web developer, or someone with the responsibility for the web interface! You need to get the API defined so you can understand how to use it and from time to time you will need to talk to them about why something is not working… maybe it is simply that you have misunderstood how it works, maybe the developer made a mistake.

1 Like