iOS - turn-based game with GameKit? - ios

From the research I've done, GameKit seems to be mostly about leaderboards and achievements. I am trying to develop a turn-based game like Words with Friends or Checkers. Can GameKit be used for this? The Game Center app seems to require you and your friend to simultaneously have the app open and invite each other to play. I want the Words With Friends approach where you receive notifications that your friend has made a move. Can GameKit do this?
If not, how is this achieved?

GameCenter can be utilized for both real-time and turn-based, check out the tutorial here: http://www.raywenderlich.com/5480/beginning-turn-based-gaming-with-ios-5-part-1. It has two parts with the second one contains most of the game logic. The project code is also downloadable.

It's worth checking out the new GameKit APIs in iOS 5. GKTurnBasedMatch should probably do the trick if you haven't rolled your own solution yet.

Using GKTurnBasedMatch in the new iOS 5 SDK will allow you to do this

I've some suggestions for you. You can use GKTurnBasedMatch class for the reference. In GKTurnBasedMatch you will find
1)Retrieving Existing Matches,
2)Creating a New Match,
3)Retrieving Information About the Match,
4)Retrieving the Match’s Custom Data,
5)Handling the Current Player’s Turn,
6)Leaving a Match,
7)Ending a Match and Deleting a Match From Game Center.
However you can also read detailed description here about this class. For more details visit following link.Thanks
http://developer.apple.com/library/ios/#documentation/GameKit/Reference/GKTurnBasedMatch_Ref/Reference/Reference.html

GameKit / Game Center can be used to solve many of the social gaming aspects you might need, but the actual game play (ala Words with Friends) would need a server that has web services created specifically for the rules of your game.
There are many threads here about webservices, here are a few:
Best way of using web services on iOS?
iPhone REST client
Using a REST API and iPhone/Objective-C

Related

Real-time game matchmaking with friends in iOS

I would like to implement friends-based matchmaking for a real-time game on iOS 8+
I can already use GKMatchRequest to do anonymous matchmaking, but I'm not sure how to let the user attempt to play against someone they already know
Possibilities:
GKMatchRequest.recipients is where you specify players to invite. But where to acquire the GKPlayer objects to pass to this property? All I can find is GKLocalPlayer.loadRecentPlayers(), which covers only 'someone you have played a game with or a legacy game center friend'.
GKMatchMakerViewController offers a UI for the user to send iMessages to people from Contacts. But the UI is confusing- is there are way to do this programmatically?
Facebook has what many users would consider their canonical list of friends. Does the Facebook SDK for iOS offer matchmaking against this list? Matchmaking is mentioned for Instant Games, but not mobile games
3rd party solution. Perhaps there's another SDK that allows listing of a user's friends/contacts followed by an invitation flow to connect them together?
My ideal UI flow would be
Tap 'Play against friends'
Select from a list of your FB friends/iOS contacts
That user receives an iMessage/FB message from which they can install or open the app
If you're still waiting for them by the time they launch the app, you are both connected and the game begins
It's been driving me a bit crazy because it seems like quite a common problem - surely many users would want to play against people they know? - but I can't seem to find a clear solution. It doesn't help that the GameCenter APIs seem to have changed a lot and documentation is a bit sparse

Is it possible to issue an alert when a GameKit opponent is ready?

I made a game using GameKit and I am using the framework to manage a real-time match between two opponents. If I invite a specific person to a match, or make sure they are "waiting for opponent" at the same time as me, the match and game goes smoothly and everything is great.
The problem I have now is that there aren't a lot of people on my app yet, and so people that are wanting to play against a random opponent who also wants to play, don't have any way of knowing when a match could be ready.
Is there a way to utilize GameKit, but enhance the experience so that a push notification or alert of some kind is sent when an opponent is found? It could be this is all built in, but I'm not seeing anything.
AFAIK, GameKit does not support push-notifications for matching real-time games while your App isn't running.
But, GameKit has a Player Activity API that tells you how many matches were requested in the last 60 seconds, and you could use that number to create an informative message or status to show the player.
EDIT: the methods in question are
- queryActivityWithCompletionHandler:
- queryPlayerGroupActivity:withCompletionHandler:

Do iOS Game Center turn based games use Apple servers?

If I implemented a Game Center game on iOS using their turn based functionality will the game operate on Apple servers alone?
No further cost to me?
I'd probably use gkturnbasedmatch from what I've seen.
I am making an iOS board game and it occurred to me that I might be able to add online multiplayer. The simplest and cheapest option for me would be if I could do it all from ios sdk. I'm not interested in paying for a server.
If it does work then what are the limitations?
Please only provide an answer if it's current. I think early Game Center was much more limited. It might not have had gkturnbasedmatch for instance.
I am developing in iOS 8 and swift.
From the Apple Documentation on Turn-Based Matches.
Game Center is primarily responsible for storing data. You are
responsible for providing the game logic that uses this
infrastructure. In particular, you define:
What data must be stored on Game Center
When the match data needs to
be updated
When play passes to another player
Limitations:
Size of matchData - 64KB
Each player can participate in up to 30 simultaneous matches in a turn-based game.
Note that games that have ended still count until the user removes them (e.g. from the GKTurnBasedMatchmakerViewController).

real time messaging for multi player game on ios

Building a multi player iOS game where players compete one against the other. Nature of the game is synchronous. Basically, players either invite each other through facebook, email, etc and then start playing.
We debate what is the best strategy for facilitating the real time communication between players (sending events, etc). Coming from web development, we used comet and long polling which worked great. However, it's not clear what's the best way to achieve that on iOS.
Seems like APN (Apple Push Notifications) is not suitable in our case for two reasons: the delay can be pretty significant, up to few seconds, as far as we understand. Also, using APN requires the user to authorize notifications. If the user doesn't authorize this then it won't be possible to play the game.
Also, we understand Apple's Game Kit (Game Center) can be of value in our case however it's not clear how it interacts with invites through facebook etc. Also, not clear if we need to get into bed with Apple's Game Center and how it'll affect the user experience.
Any guidance on this matter as well as other options that you might think of would be greatly appreciated.
Thanks for your help.
Before you read the rest, a disclaimer: I work for Realtime.co but I do believe I can help here so I'm not trying to "pitch a sale".
If you need to have real time updates, you can check out Realtime (www.realtime.co). It's basically a set of tools for developers to use real time technologies on their projects. It uses websockets but does fallback to whatever the user's browser supports (such as long polling, for example) if you are using a browser (which is not your case, but it's always good to know).
Behind Realtime you have a one-to-one/one-to-many/many-to-many messaging system that will transport your messages to and from your users.
There's a iOS API too which you can use in your project. You can download it here: http://www.xrtml.org/downloads_62.html#ios and check the documentation here: http://docs.xrtml.org/getting_started/hello_message.html#ios.
There's also a plus which is the fact that the Realtime framework is actually cross-platform. This means that you can even have your iOS players to communicate with players using Android, Windows Phone, HTML5, Flash, etc. if you decide on expanding your game to other platforms.
I hope that helps!
I'll just provide some insights on the question.
APN should never be used for synchro communication as for iOS at least, you'll never have both way communication (basically the Apple APN servers are pushing an information to the device).
You should probably play with C sockets in order to open a tunnel (depends if your game is real time or not).
Using the Apple Framework GameKit is great! But might take some time to understand all the functionnalities.
Check out Gree
https://developer.gree.net/en/
Parse:
https://www.parse.com/
Sparrow:
http://gamua.com/sparrow/
There are a few things that your talking about, there is the joining/starting of a game, and then the communication between the players. They are not necessarily related.
You can use game-center and at the same time another framework for facebook, they are not mutually exclusive (but it would be more work.)

I want to build a massive social async game mode into my iOS game, is there an iOS API for that?

I’m building my 2nd game now and I’m wondering if there’s an iOS API to help me out with building a social async game. I’ve used GameCenter before (for leaderboards) but I don’t think GameCenter is something I can use for this.
Are there any open source components I can use instead? Something like the Facebook SDK?
Would I need to have the game run on a server?
You could actually use GameCenter for some of the things you wish to build. For instance, there’s a built-in mechanism for matchmaking and turn based style games. You can have a look at GKTurnBasedMatch for more information.
However, GameCenter does have its limitations. There’s a great blog post by Andrew Plotkin that describes his experience with building a GameCenter based turn-based game. In short, using GameCenter is a bit convulted, one of the players in the match needs to constantly maintain the game state (since it’s all client based) and there is no possible way for both players to act simultaneously. Also, there are issues with players logging out of games (Apple doesn’t provide a mechanism for forfeiting the game or skipping someone’s turn).
You could always take the long road and implement the game using your own server. You would need to build several mechanisms like registration, matchmaking, push notification integration, storage and of course client to server communications.
Another option to consider would be to use Nextpeer’s SDK. They provide a complete solution for games that wish to incorporate a “play with friends” feature and it’s free. They take care of the matchmaking, push notifications and all server-side logic. The game itself just needs to implement some simple methods like starting a game, reporting score and ending a game. It’s pretty easy, they have a simple screencast here that shows how to do it.

Resources