For my task how should you communicate between iph

2019-08-17 15:24发布

问题:

I have a situation where I would like to communicate between 2-4 devices over the 3G network (it should also work over WLAN, but 3G solution is critical).

Every device (except one) asks for a GPS-location every ~5 seconds, but when this process is cancelled by the user of that device, one device needs to be informed of this event.

I was thinking that one device could act as a server, and the rest as clients that should connect to the server. Is this possible over the 3G network?

I've also read about push-notifications, is this relevant here? Can you receive notifications without disturbing the user with a popups etc?

Are there other ways?

Basically I would like to use apple "standard" solutions (if there are any) before diving into eventual socket-programming or anything similar...

What I would like to avoid is to have a webserver or some similar "3rd-party" solution, because I don't want many users to simultaniously connect and "pull" from the same external server in a final solution...

UPDATE:

Basically my application will have thousands of users that will need to be informed if an even occurs. Also this happens simultanously ~5 second, what would be the best solution to reduce load and avoid spamming?

回答1:

I was thinking that one device could act as a server, and the rest as clients that should connect to the server. Is this possible over the 3G network?

It could work, but having a dedicated server would be a better choice

I've also read about push-notifications, is this relevant here? Can you receive notifications without disturbing the user with a popups etc?

In your case no, since you will need a server to communicate with apple

Basically I would like to use apple "standard" solutions (if there are any) before diving into eventual socket-programming or anything similar...

There are no standard solution, other than you should probably rethink about using a dedicated remote server for this



回答2:

iPhones can't communicate directly with each other using 3G. You can access the internet through the 3G, but you can't do peer-to-peer as you are suggesting. If you were close enough, you could use bluetooth, but I expect you are too far away.

You would have no way of detecting the one device that acts as a server from the other devices. The IP address could (and probably would) change every time the device connects to a mobile data network. You would need a central server to co-ordinate all of the clients.



回答3:

You have multiple questions, but I'll try to address as many of them as I can:

I was thinking that one device could act as a server, and the rest as clients that should connect to the server. Is this possible over the 3G network?

No, you cannot run a server on a iPhone/iPad that is accessible over 3G without an external website acting as an intermediary. (You can run one that is accessible over Wi-Fi, but this does not solve your problem as stated.)

I've also read about push-notifications, is this relevant here? Can you receive notifications without disturbing the user with a popups etc?

Push requires you (or a third party contracted by you) to have a web server, so if you want a server-free solution it is not relevant here.

Are there other ways?

Over 3G you will, under the current Apple restrictions, always need an external server.

Basically I would like to use apple "standard" solutions (if there are any) before diving into eventual socket-programming or anything similar...

Diving won't help you here. Even using low-level socket programming you will not be able to run a server on an iPhone accessible over 3G without an external website to aid in establishing a connection.



回答4:

You can try using GameCenter. The mechanism of network games in Game Center allows connect up to four players with no third-party solutions.