Reputation: 261
I am using notification to send entries on client from server, but it might be possible that any notification gets missed out due to some issue, which is difficult to track. Now let's have entry 1,2,3,5,6,8,9 on client but on server 1 to 9. As two notification caused some issue and not able to reach client, so client missed entry number 4 and 7. How do i make sure that when client next time starts application, i can sync entry 5 and 7. One way is every time client syncs, i send all entries client have but that is not a feasible solution if data is too large.
When user clears his data, i sync complete data to it, so that case is fine.
How i handle above mentioned scenario in a sophisticated manner?
Upvotes: 3
Views: 902
Reputation: 338
I think your client should be able to identify which entries are missing and request for those entries only to the server. If there is not such existing way to identify missing entries on client side then you should implement one if possible.
Other way could be if server can keep track of missing entries by requesting acknowledgement for the notification delivered to the client and push the missing entries again.
Upvotes: 2
Reputation: 336
We do something similar to what @SimonSays answered. All notifications or pieces of data to be sync with the client have its own id and a flag indicating whether the client has received it or not.
Then, we provide two rest methods in the back-end, one in which the client uses to get new entries (those entries not marked as received), and another in which the client notifies which ids he has received (like an ACK). The client DOES not sent an ACK for each data. Instead, sends one single request with a list of id's received.
Upvotes: 3
Reputation: 10977
It depends on your data. Do the entries have a timestamp or an id? One possibility would be to send only a "data_changed" event as push notification. The client would then pull the new data. Add the timestamp, id or whatever to the server call to identify the last known entry. The server sends will then send all the new data.
Upvotes: 0