So I have encountered a problem and have two solutions to it that I need some feedback on. Or perhaps a better solution
I have two android devices that communicate with each other through a server. All the requests to the server are done by REST and all the requests by the server to the phone is done by push messages(using Firebase).
In my app, without trying to reveal to much info, one device A need to tell device B that something have happen. But before it does that, it need to check if device B is within close proximity. And if they are, ignore the message.
Idea 1:
1) Device A sends a REST request to the server, telling that something
may have happen. Also include device A's GPS coords.
2) Server ask device B for its GPS coordinate by sending a push notification.
3) Device B receives the push message and sends a REST request to the server, containing its GPS coords.
4) Compare the GPS coords and determine if they are close to each other. If not, send a message to device B, telling it something have happen.
Idea 2:
1) Device A check if it can connect to device B or if it is connected to device B via Bluetooth.
2) If not, send a REST request to the server, telling that something definitely have happen.
3) Server simply forward the message to device B.
While idea 2 sounds easy and better, I am suspicious towards the use of Bluetooth. Basically, I am not use it's possible for device A to know that it actually is device B. So I am questioning the reliability of the second idea.
The first idea is on the other hand hard to implement. And I simply don't like it.