I cannot get GameCenter invite friend to work. The match maker view controller shortly shows the invited player and a little text "Failed" under it. Maybe I picked the wrong time to learn GameCenter, as quite a few people report difficulties with iOS9. But maybe there is a solution somewhere.
Basics:
- iTunesConnect App record exists, app is not public, GameCenter is enabled, one leaderboard has been created, two sandbox users have been created (different from my main apple id)
- The app has one view controller, which for now shall handle all GameCenter things
- In
viewDidLoad
the player authentication is started by assigning a block to[GKLocalPlayer localPlayer].authenticateHandler
. In the block the passed in view controller is shown (if there is one). This works. - The view controller is set as
GKGameCenterControllerDelegate
and it works, the "didFinish" call is received and I dismiss the GameCenter view controller there. - In the authenticateHandler block, when the player is authenticated, I set the view controller as listener with
[[GKLocalPlayer localPlayer] registerListener:...];
. A method stub for allGKLocalPlayerListener
methods is implemented with a log call. - When tapping a certain button, I create a
GKMatchRequest
and theGKMatchmakerViewController
, set my view controller as matchmaker delegate and present the matchmaker view controller. Again all delegate methods are implemented with log calls. - I can run the app, in the matchmaker view controller tap "invite friend" and follow the screens until I tap the "Send" button. Then the invited player is shown on the right slot, shortly "Failed" is shown below it and "Auto-match" is shown again.
- No player listener methods are called.
Questions:
- Do I need to enable push notifications to make invite friends work? (If yes, where is this documented?)
- Is it possible to test invite friends between simulator/simulator or device/simulator or only device/device?
- What does "No registration for peer" mean in the GameKit log from a device? (see below)
Other resources:
- Is Game Center Multiplayer Friends broken in IOS 9? (Oct/2015)
- How to solve inviting friend over game center? (2013)
- http://www.raywenderlich.com/60980/game-center-tutorial-how-to-make-a-simple-multiplayer-game-with-sprite-kit-part-1 (CatRace - March/2014)
- Game Center invite fails immediately (Oct/2015)
GameKit Logs:
I turned on GameCenter logging in the settings on my iPhone and exported the logs. The first thing, which caught my attention is this "No registration for peer (...)":
<NSHTTPURLResponse: 0x167a2cc0> { URL: https://service.gc.apple.com/WebObjects/GKInvitationService.woa/wa/initiate } { status code: 200, headers { ... }
...
status: (200) no error
header: <CFBasicHash 0x165e6480 [0x3b6633e8]>{type = immutable dict, count = 10,
entries =>
...
body: <CFBasicHash 0x17811ad0 [0x3b6633e8]>{type = mutable dict, count = 4,
entries =>
...
3 : <CFString 0x38bc0f78 [0x3b6633e8]>{contents = "message"} = <CFString 0x165c0610 [0x3b6633e8]>
{contents = "No registration for peer (G:<stripped>/?/?)"}
...
9 : <CFString 0x38bb53d8 [0x3b6633e8]>{contents = "status"} = <CFNumber 0x165cacc0 [0x3b6633e8]>{value = +5030, type = kCFNumberSInt64Type}
}
EDIT 1:
Forgot the next entry from the log: (manually wrapped)
[(gamed:123:NO):Error] invite failed with error: Error Domain=GKErrorDomain Code=3
"The requested operation could not be completed due to an error communicating with the server."
UserInfo={GKServerStatusCode=5030, NSUnderlyingError=0x167528a0 {Error Domain=GKServerErrorDomain
Code=5030 "No registration for peer (<stripped>)"
UserInfo={GKServerStatusCode=5030, NSLocalizedFailureReason=No registration for peer (<stripped>)}},
NSLocalizedDescription=The requested operation could not be completed due to an error communicating with the server.}
EDIT 2:
I tested with two non-sandbox accounts on two devices attached to two different macs running Xcode 7.1 / both devices on iOS 9.1. In either direction I still get the "Failed" message in the game center match maker screen.