Currently I have an IOS chat app that runs with firebase. The app is working fine and sending and receiving messages when two users are online. I am using real-time database, however when one of the user is offline (i.e application is killed or even the app is running in background) and the other user is sending a message the messages are not received. Is there is a way where can I know the current state of the user and instead of sending the message I send a notification to notify him that there is a new message.
Asked
Active
Viewed 66 times
0
-
What you're describing is known as a presence system. The Firebase documentation has a good description of it: https://firebase.google.com/docs/database/ios/offline-capabilities#section-presence. Also see https://stackoverflow.com/questions/44016521/firebase-presence-system-in-ios-application – Frank van Puffelen Jul 12 '18 at 19:29
-
@FrankvanPuffelen thanks for the answer. I have another question. Now I can ensure that the message will be delivered even if the use is offline using data persistence. Is there is a way to send a notification when the user is offline that he has a message ? – Ahmed Jul 12 '18 at 19:37
-
Being offline is a bit broad. But if you want to deliver a notification to a user that isn't currently actively using the app, that would be Firebase Cloud Messaging. See https://stackoverflow.com/questions/45972788/how-to-receive-a-notification-to-android-user-when-ever-firebase-database-is-up, https://stackoverflow.com/questions/38022413/firebase-notification-on-child-added-modified – Frank van Puffelen Jul 12 '18 at 21:25
-
Note that we've now gone through a number of distinct topics in a few comments. Your question is really incredibly broad, which makes it hard to provide a single answer. Please keep this in mind when posting on Stack Overflow: telling you how to implement a use-case is much harder than helping you on a concrete step within an implementation. – Frank van Puffelen Jul 12 '18 at 21:30