0

I want to make an IOS real-time game/app, the game itself is only based on the location of the two players devices, so there is no game graphics.

There should be some way to make a match with any random person across the world, then send data between those two players.

So, my question is, can I use Game Center to achieve all of this or not, I searched a lot but still feeling lost where to start, as I also ran into PubNub, which can send real-time updates throw the devices, but the point is that, can it also help me making matches with random players around the world?

And as I know the apps which are not games and use Game Center are getting rejected by App Store, so how can I avoid this if my app only uses maps in the game/app?

TheNeil
  • 3,321
  • 2
  • 27
  • 52
Battle Eagle
  • 166
  • 7
  • PubNub has new features since this question was answered 3 years ago: [Android - correctly pairing and connecting two users in a random chat app using parse and pubnub](https://stackoverflow.com/questions/33737457/android-correctly-pairing-and-connecting-two-users-in-a-random-chat-app-using). I've asked our DevRel team to review this and possibly post a more modern approach using those new features. Stay tuned for more... – Craig Conover Apr 12 '19 at 18:24

1 Answers1

0

Yes, this is an ideal use case for PubNub. Your app's client code can publish a message when the app starts. This message should be published on a channel named something like join of global and it should indicate that the user is available for a new game.

Your server code should use a PubNub Subscribe, to listen, with an always-on connection. That way, as soon as someone is ready to be matched for a game, your server can queue the user to be matched with an opponent. Once an opponent is selected, the server can publish on a personalized channel for the individual users, or the pair of users, with real-time data pertaining to the match.

Those personalized channels can be based on the user's unique ID like this:

user-1

user-2

user-1_user-2

Any PubNub-connected device can Publish and Subscribe to multiple channels at any time. See the PubNub iOS SDK documentation for code snippets you can paste into your application.

Adam
  • 659
  • 4
  • 13