cocoa - Implementing GameKit.framework on OSX, cannot authenticate localPlayer -
i'm attempting implement gamekit in osx game. unfortunately can't find information how this; tutorials seem ios (though the documentation states "game center available on ios , os x").
everything compiling fine; problem comes when try authenticate local user:
[[gklocalplayer localplayer] setauthenticatehandler:^(id viewcontroller, nserror *error) { if(error) { dlog(@"error: %@",error);// returning error } else if(viewcontroller) { // do here?? } }];
i have 2 problems:
first, handler gets error: error domain=gkerrordomain code=6 "the requested operation not completed because local player has not been authenticated." userinfo=0x10103bc70 {nslocalizeddescription=the requested operation not completed because local player has not been authenticated.}
.
second, don't know how present view controller.
on iphone, code works fine: there's no error, , present viewcontroller (which login screen).
i'm sorry, , realize answer year late, in case may still relevant others still asking question myself. ed marty correct, i've discovered works me this.
[[gklocalplayer localplayer] setauthenticatehandler:^(nsviewcontroller < gkviewcontroller > viewcontroller, nserror *error) { if(error) { nslog(@"error: %@",error); } else if(viewcontroller) { gkdialogcontroller *presenter = [gkdialogcontroller shareddialogcontroller]; presenter.parentwindow = mywindow; [presenter presentviewcontroller:viewcontroller]; } }];
the main difference using nsviewcontroller conforming gkviewcontroller instead of id.(also, used nslog instead of dlog, isn't important).
"i have found, however, useless, , presents login dialog before calls handler."
to make sure works, set new game center account through app. when run program , loads window sign in, press "create new apple id" if have apple id. button may not work, if that's case, open game center , press "create new apple id." either way, objective create "sandboxed" game center account, can learn more here: https://developer.apple.com/library/ios/documentation/networkinginternet/conceptual/gamekit_guide/testingyourgamecenter-awaregame/testingyourgamecenter-awaregame.html#//apple_ref/doc/uid/tp40008304-ch17-sw1
you can tell if account sandboxed if when reading terms , conditions, word "sandbox" appears on yellow banner in top left. once again, i'm sorry i'm late, clears topic future viewers.
p.s. i'm sorry code did not format properly.
Comments
Post a Comment