leecrossley / cordova-plugin-game-center

Cordova / PhoneGap Game Center Plugin for Apache Cordova >= 3.0.0
http://ilee.co.uk
78 stars 29 forks source link

Get game center user nickname? #13

Closed PixelRaven closed 10 years ago

PixelRaven commented 10 years ago

This is a great plugin!

I just was wondering... Is it possible to retrieve the user's nickname from the game center? This would be extremely useful for me. Sorry if this is not the best place to ask this.

mulhoon commented 10 years ago

+1 That would be awesome

mulhoon commented 10 years ago

I added this on line 28 of Gamecenter.m as a quick fix. Worked for me but not sure if it's the right way to go..

NSDictionary* user = @{
         @"alias":localPlayer.alias,
         @"displayName":localPlayer.displayName,
         @"playerID":localPlayer.playerID
};
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:user];

and then use...

gamecenter.auth(function(result){
    console.log(result.alias);
}, function(result){
    //
});

Great plugin!

leecrossley commented 10 years ago

That seems like a nice way to do it - I'll get this into the master branch today (feel free to pull request if you like).

Thanks for your contribution :)

mulhoon commented 10 years ago

Thanks, I've done a pull request.

leecrossley commented 10 years ago

I've tested these and they work OK for me - thanks