0

I do not know whether this is an appropriate question for this site or not. However, searching the Internet has not lead me to anything. I have searched some other questions on this site related to Inter App Communication and they are not really quite what I wanted.

I am creating 2 apps. Let's call them App A and App B. They would be used to keep track of visitors to a particular community. Now, whenever a visitor enters the apartment details of the Unit that he wants to visit in App A, a notification should be sent to the current resident of the Unit (he will be logged into the app). I will be achieving this using Firebase Cloud Functions/Messaging. Now, when the resident of the unit approves the notification, App A should be communicated the approval/rejection.

I am having trouble with the latter part. How do I communicate a value between 2 apps?

Also, I am open to suggestions on other ways to approach this problem.

EDIT: Also, I forgot to mention that these apps will be running on different devices.

To make things clear, I would like to put forward the way I am thinking of approaching it. The Visitor enters his details in App A. They go into a Firebase Realtime Database. This would trigger a Cloud Function. This Cloud Function would send a notification to the logged-in user on App B. The user of App B would then approve or reject the Visitor. I need a way to communicate this decision to the other app.

EDIT 2: After doing a bit more research on this topic, I discovered the Pub/Sub model. Would that model work for the task that I have described?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Rohit Shinde
  • 1,575
  • 5
  • 21
  • 47
  • I think you are looking for Broadcast receiver. Maybe https://stackoverflow.com/questions/33492790/how-to-send-broadcast-from-one-app-to-another-app will help – Boardy Jan 11 '18 at 16:28
  • Would it work if the apps are on different devices? On a side note, are two apps really needed for this. Is it possible to do this with only one app? – Rohit Shinde Jan 11 '18 at 16:32
  • Oh if there on different devices then no it won't work. The broadcast between the apps will have to be on the same device. You could use Google Cloud messaging (it might be part of firebase as well now) to send a notification between the device and the app, although not sure how that works off hand. Keeping it as two separate apps would probably be easier for maintainability, if there was a bug in the apartment owner app you only need to update them, not the app for the visitors – Boardy Jan 11 '18 at 16:49
  • GCM/FCM is not an ideal solution for this. This is more like a realtime chat application. Would be best to use protocols like XXMP or MQTT for such kind of communications. You might have to setup your own server in this case, cloud functions might not be sufficient. – Umang Jan 11 '18 at 17:01
  • @Boardy Notification can be sent using Cloud Messaging. But how can I communicate the response to the Visitor's app? – Rohit Shinde Jan 11 '18 at 17:10
  • @UmangChamaria What do you think about my second edit? Using Pub/Sub? Also, did you mean XMPP instead of XXMP? – Rohit Shinde Jan 11 '18 at 17:11
  • Pub/Sub via GCM not very sure, haven't explored it much. Problem statement looks like more of chat app, instead of messages it has actions, hence suggested XMPP, MQTT these protocols are used by biggest chats apps like Whatsapp and Facebook Messenger – Umang Jan 11 '18 at 17:14
  • I just looked up MQTT. It is a lightweight Pub/Sub model. So I guess GCM Pub/Sub model would also work quite well here. – Rohit Shinde Jan 11 '18 at 17:17
  • @RohitShinde If I remember correctly you'll need a server backend (its been a while since I've done it so I may be mis-remembering or it might have changed) but the app A sends the GCM to your backend service, you process it and then send a GCM to app B to the device that is running it. So I think you'll need to keep a database of devices that are on A and devices that are on B so you send it to the right device as required – Boardy Jan 11 '18 at 21:00

0 Answers0