c# - GKLocalPlayer.LocalPlayer null on some simulators -
i'm having issue integrating game center monogame game.
what have:
void initgamecenter() { gamecentermanager = new gamecentermanager(); setauthenticatehandler(); } void setauthenticatehandler() { gklocalplayer.localplayer.authenticatehandler = (ui, error) => { if (ui != null) { controller.presentviewcontroller(ui, true, null); } else if (gklocalplayer.localplayer.authenticated) { currentleaderboard = gamecentermanager.reloadleaderboard(leaderboardid); } else { var alert = new uialertview("game center account required", "need login game center!", null, "retry", null); alert.clicked += (sender, e) => { //gklocalplayer.localplayer.authenticated(); }; alert.show(); } }; }
on simulators stops @ first line of code in setauthenticatehandler() method throwing exception because gklocalplayer.localplayer null.
where works:
ipad 2 (9.2) device every simulator of iphone newer 5 (iphone 5s, 6, 6s whatever ios version).
where doesn't work: every iphone simulator older tan 5s (iphone 5, 4s)
the methods showed in appdelegate's finishedlaunching() method, since there no viewcontroller.cs in monogame.
any clues?
could signature issue. take @ class details. signature changes @ ios 6.
from docs:
// // shows how authenticate on both ios 6.0 , older versions // if (uidevice.currentdevice.checksystemversion (6, 0)) { // // ios 6.0 , newer // gklocalplayer.localplayer.authenticatehandler = (ui, error) => { // if ui null, means user authenticated, // example, if user used game center directly log in if (ui != null) current.presentmodalviewcontroller (ui, true); else { // check if authenticated: var authenticated = gklocalplayer.localplayer.authenticated; } console.writeline ("authentication result: {0}",err); }; } else { // versions prior ios 6.0 gklocalplayer.localplayer.authenticate ((err) => { console.writeline ("authentication result: {0}",err); }); };
Comments
Post a Comment