F
F
FlooDwm2016-10-12 23:02:39
iOS
FlooDwm, 2016-10-12 23:02:39

Swift 3.0 Core Data - background update?

Essence of the question. There is a database on the phone, it is necessary to check for updating the database on the server. DURING APP LAUNCH AND SUPPOSE ONE MORE TIME A DAY in the background. Where to attack, all read all some kind of dregs.
Explain exactly the logic of actions! For example, according to the latest update date. How to compare how to supplement the base only using MINIMUM TRAFFIC.
PS - Server - PHP - MySQL
- On the phone Core Data

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sojik, 2016-10-14
@FlooDwm

You need to set up the Background Fetch capability in the project
Then implement one method - application(_:performFetchWithCompletionHandler:) - that will quickly request updated data from the server
More details here - https://www.raywenderlich.com/92428/background-mod.. - section about Background fetch
The update logic itself is up to you. For example, if you have a chat, then you request messages greater than id that are already in the database. Or messages whose date is greater than those already in the database. Usually, you can put the same query that you use when you start the application to update the data in this query. But keep in mind that the phone itself chooses when to request a data update - it can be every 10 minutes, or it can be hours.
That is one more time. Your phone in the background accesses Core Data and finds out the date of the last data, or id or something. Based on this, requests new data from your server. The received data is parsed and added to Core Data and put back to sleep, until the next wake-up by the system.

I
Igor Cherny, 2016-10-13
@freeg0r

Recently met in Appboy there is a background push feature (APNS) that can start a background process in an app. In addition, you can trigger a Core Data update in the background when the user exits the application, or if they find geolocation tags. Here you can see the plate, everything is clear in my opinion https://developer.apple.com/library/content/docume... ..and this does not depend on Swift..

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question