iOS8でGameCenterのユーザチェックを行う

September 21, 2014

iOS8でGameCenterのユーザチェックを行う際にちょっとハマったのでメモ。

はまったこと

ユーザ認証のエラーが発生してGameCenterが利用できないように見える。

コード

func authenticateLocalPlayer() { let player = GKLocalPlayer.localPlayer() player.authenticateHandler = { [unowned self] (viewController: UIViewController!, error: NSError!) -> Void in if (viewController != nil) { self.presentViewController(viewController, animated: true, completion: nil) } } }

(恐らく)問題の原因

実機でサンドボックスモードをONにしていなかったからかな。(参考: xcode - Game Center not authenticating using Swift - Stack Overflow

Sandbox

申請前にはちゃんと製品版でも使えるか確認しよう。


Profile picture

Written by morizotter who lives and works in Tokyo building useful things. You should follow them on Twitter