开发者

iOS and game center - picking friends for hosted games

I'm experimenting with adding Game Center support to our game. It already has OpenFeint support but we'd also want to support GC.

The basic authentication and usage is quite easy and seems to work quite well (apart from that the sandbox is terribly unstable). However, due to our architecture we would like to use GC mainly for picking friends, not using the full invitation support. So, I'm looking for a way to use something like GKMatchmakerViewController to only pick friends, not send invites to them. I'd like to show the normal view where the player can select the friends and then just return the picked friends, I don't want the view/GC to send anything at all to the picked friends.

    GKMatchmakerViewController * mmvc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease];
    mmvc.matchmakerDelegate = my_delegate;
    mmvc.hosted = YES;

This should according to the docs call my delegate's didFindPlayers method, but it doesn't seem to work. The hosted flag has no effect, both with and without it GC seems to try to send something to the picked friend(s) and then briefly shows a text Incompatible in the UI and and disregard the picked friend.

Do I do something fundamentally wrong here or is what I want to do just not possible? What does the Incompatible error ac开发者_JS百科tually mean? I'm running between two iPads that both have sandboxed users logged in. Is picking friends without notifying them actually possible?

Edit:

The Incompatible message that the GKMatchmakerViewController shows when I try to pick friends is weird. I have not found any documentation as to what it might mean and what could cause it. A simple guess is that GC somehow thinks that the sandboxed users have different versions of my game installed and these are somehow not compatible. This game is already available in the app store, but without GC networking. Could the sandbox environment somehow pick up some information from that? No old version of the game is installed on the pads though.


To those who still experience this issue. Take a look at your build phases, Run Script section. In my case I used one of these scripts that automatically increases build number, its a common practice to keep track of such things. But, Game Center will not get along with this approach. The script actually takes CFBundleVersion and increases it by 1 (there are various techniques, the one I use just does +1).

#!/bin/bash
buildPlist=${INFOPLIST_FILE}
CFBundleVersion=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" $buildPlist)
CFBundleVersion=$(($CFBundleVersion + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $CFBundleVersion" $buildPlist

So I install build on iPhone, it's build number is, say, 295, then I install it on iPad and it has 296 build version, which is same as bundle version. And the two versions are incompatible from Game Center's point of view.

The normal (instant) multiplayer mode just says "Incompatible" when trying to invite a friend. Turn-Based mode will not show anything useful at all.

The whole thing is confusing, since on iTunesConnect in Game Center compatibility list it shows short versions strings (CFBundleShortVersionString), so I assumed as soon as I put same value in "Version" field of project settings, it will work. It doesn't though, the "Build" must be same as well.


I can confirm that the CFBundleVersion in the Info.plist must match exactly. I had one device with version "4.00" and the other one at "4.0", and I was getting the 'Incompatible' message. Changing them both to "4.00" resolved the issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜