Reputation: 1078
when a certain condition is true, I need to send a message to a certain device that has my app installed. How can I realize it? E.g. A klicks on the name B, B shall get an AlertDialog that A clicked on his name. I know that I will need something like a deviceID. But what else?
Upvotes: 1
Views: 67
Reputation: 8371
If the recipient device currently has your app running and is connected, then the app you would presumably maintain a connection to a server or implement polling by the app.
For a non-running recipient app, you'll either have to utilize a standard messaging protocol (SMS, email, etc.). Or you will have to implement a background service in your app that periodically wakes up and polls a server that maintains the messages. This is how Twitter, Facebook, etc. work.
Just to be clear, opening or maintaining direct network connections between multiple devices not on the same local network is not really doable.
Upvotes: 1
Reputation: 8170
You don't need a device ID, you need a server that handles the communiation between the two devices.
In order for a device (A) to communicate directly to another device (B) without a server, A needs to know who B is and how to reach it.
The usual solution is that both devices connect to a server through the network, using a particular protocol. When A want's to send a message to B, it does it through the server, which forward the request to B (since B is also connected to the server). In order to identify the devices you can use any information bit you want (it can be a user name, such as in chat systems, it can be the device ID which is not very reliable...)
Upvotes: 1