简体   繁体   中英

Listen remote database changes

How do I make my server to notify client about something? For example a change in database ? I already know about FCM. But what if I don't want to use it ? How do I code that networking logic myself?

I currently don't need it. But i am very curious about how that push system works

In case you want to push your data from the server to your Android clients and don't want to use FCM:

You could always use web sockets, which can be a pain to implement manually on both Android and the server. For this the app should either be in the foreground or you could use a Service. We started with this library for Android: https://github.com/koush/AndroidAsync

Now, we use Pubnub for our projects, which builds on top of web sockets and gives you a way easier way to handle those. You would still need to have the receiving part in foreground or a Service. But it also gives you the possibility to use FCM (or Apples Push Service) as a fallback, which is the easiest way to receive pushed data in the background. It starts out free but then will cost you when your usage goes up. You can take a look here: https://www.pubnub.com/

PubNub for Realtime Messaging

You should read this article on how to publish a message via a database trigger .

For details, see How PubNub Works here .

But to summarize for you, you simply have your clients subscribe to a channel(s) and your server publishes messages to those channels. You decide on channel names and what data to publish on them and when to publish the data.

PubNub takes care of delivering those messages to the subscribers of those channels in less 1/4 second.

You can subscribe from any platform:

That's just three of over 70 platforms that you can choose from. Free account allows up to 100 daily active devices (forever) so that you can play before you pay, if you decide to scale your app to the masses.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM