0

I have both an app and a website. One of the features of my website/app is that users can follow other users (much like Twitter).

Right now, I have it set up such that, when the user logs into the app, the app also requests (from the web server) all of the users that person is following (using Retrofit), and then populates the navigation drawer with each of these users (for easy access to their profiles).

However, what if the user follows someone else through the website (not the app). This is a problem because the app only retrieved all the users the person is following on sign in. So if the user opens the app (already signed in from their previous session), the list of users they're following will be outdated.

So my questions is, how and when should I update the user's list of people they're following? How do other apps usually handle this sort of thing?

Amit Upadhyay
  • 7,179
  • 4
  • 43
  • 57
  • You should always be receiving the followers from the web-server if you want to keep in-sync – OneCricketeer Feb 06 '17 at 17:35
  • One of the way is to use SyncAdapter, it is a robust, standard solution but might be overkill for your simple use case. https://developer.android.com/training/sync-adapters/creating-sync-adapter.html Also see, http://stackoverflow.com/questions/25887118/how-to-develop-an-offline-first-native-android-app – Sangharsh Feb 06 '17 at 17:36

3 Answers3

0

You can use Alarm manager and Service to get data from server in specified time intervals. For example every 5 minutes

0

You can achieve your desired functionality using below methods:

  1. Long pooling (non recommended)
  2. Sockets (Sockets.io)
  3. GCM or FCM
Haris Qurashi
  • 2,104
  • 1
  • 13
  • 28
0

You can simply use Firebase Realtime Database which can sync all your data across all platforms (website/app) very easily. You can specify security rules in the database so as to manage access levels for all your users. Link : Firebase Realtime Database

shikhar bansal
  • 1,629
  • 2
  • 21
  • 43