Force show game center login

Hi,

I would like to know if it is possible to force show the game center login window, which is showed during gameNetwork.init() call?

I would like to add a button, for users to be able to login to game center if they have cancelled the login previously.

Like most things on iOS, developers can access limited SDK features.  Logging people out of GameCenter would be a very unexpected behavior for App users and Apple would highly frown upon such activities.  We don’t have a way of doing it in Starter or Pro.  If Apple did permit it, you would be able to do it with Enterprise. 

Hello Rob,

I don’t want to log out people, I want to log them in.

Just like I do when I call gameNetwork.init()

Unfortunately we can only call it once, after that it has no effect.

I guess you are right in saying that it might be Apple limitation, I just wanted to make sure that my idea is not misunderstood.

I’ve got some features available only to users who are connected to game center. So when they get information that a feature is not available to them, I would like to be able to give them a button, which when tapped would open game center.

Krystian

Is it possible for you to keep the state of the GameCenter login? In that way you could skip the init. I am not sure if this would work, but it might be a solution…

hi jensto, solution you proposed would not work for me.

The scenario I wanted to handle was:

  1. User starts the game not logged in to game center

  2. User has the game center login screen and does NOT login to it

  3. User finds a feature which requires game center

  4. User gets a popup with info saying that this particular feature requires game center, with two buttons:

login to GC / cancel

I am unable to do something like that.

I thought that calling gameNetwork.show() would help, but it doesn’t work for users not logged in to game center previously.

Could you just redirect the user to the GameCenter app? This example is “stolen” from Rob Miracle’s page:

http://omnigeek.robmiracle.com/2011/06/13/implementing-a-game-center-button-in-your-corona-sdk-game/

And it goes like this (with new widget instead of old UI button…)

local widget = require( "widget" ) local function testNetworkConnection() local netConn = require('socket').connect('www.apple.com', 80) if netConn == nil then return false end netConn:close() return true end local function gotoGameCenter() local device = system.getInfo ( "environment" ) local appURL = "gamecenter:" if device == "simulator" then print ( "Cannot spawn this URL in the simulator" ) else if testNetworkConnection() then system.openURL ( appURL ) end end end local myButton = widget.newButton { left = 100, top = 200, width = 150, height = 50, id = "button\_1", label = "GameCenter", onEvent = gotoGameCenter, }

Ahh you see.

Now you’ve nailed it!

Thanks a lot, the gamecenter: url was exactly what I was looking for! :slight_smile:

Cheers!

Really glad it helped!

Can see some negatives though… You are ejected from your app and you do not land on your game’s “page”. Might be better than nothing.

Let me ask a question (instead of answering it).  What happens if you call gameNetwork.init() and the person declines to login and then  later try to make a gameNetwork.request()?   I would hope gameCenter would be smart enough to prompt to login when needed. 

Rob… why would you put Apple and smart in the same sentence? :slight_smile:

nothing happens when you call any of the gameNetwork functions if the user is not logged in.

The engineers have confirmed that the expected behavior is that if an app’s user declines the login when your app runs, that the app should not prompt them again and if they do, they would need to goto the game center app and sign in through there.  I’m guessing that you can use the call back listener and determine when gameNetwork.init() is called if they got logged in or not and remember that state and if they want to use GameCenter features later, you could use system.openURL() to the URL scheme for GameCenter to load that app.

I’m implementing GC and testing cancelling out to see what happens then. Now I can’t get it to log in again to continue testing, even after removing and reinstalling the app (even making a new build).

Rob said:

…if an app’s user declines the login when your app runs, that the app should not prompt them again and if they do, they would need to goto the game center app and sign in through there.

I’m having problem doing that since it was Sandboxed and now I only see the non sandboxed Game Center.

Any ideas?

Have you logged out of the game center app?

Thanks Rob,  logging out of the non sandboxed account did it.

Like most things on iOS, developers can access limited SDK features.  Logging people out of GameCenter would be a very unexpected behavior for App users and Apple would highly frown upon such activities.  We don’t have a way of doing it in Starter or Pro.  If Apple did permit it, you would be able to do it with Enterprise. 

Hello Rob,

I don’t want to log out people, I want to log them in.

Just like I do when I call gameNetwork.init()

Unfortunately we can only call it once, after that it has no effect.

I guess you are right in saying that it might be Apple limitation, I just wanted to make sure that my idea is not misunderstood.

I’ve got some features available only to users who are connected to game center. So when they get information that a feature is not available to them, I would like to be able to give them a button, which when tapped would open game center.

Krystian

Is it possible for you to keep the state of the GameCenter login? In that way you could skip the init. I am not sure if this would work, but it might be a solution…

hi jensto, solution you proposed would not work for me.

The scenario I wanted to handle was:

  1. User starts the game not logged in to game center

  2. User has the game center login screen and does NOT login to it

  3. User finds a feature which requires game center

  4. User gets a popup with info saying that this particular feature requires game center, with two buttons:

login to GC / cancel

I am unable to do something like that.

I thought that calling gameNetwork.show() would help, but it doesn’t work for users not logged in to game center previously.

Could you just redirect the user to the GameCenter app? This example is “stolen” from Rob Miracle’s page:

http://omnigeek.robmiracle.com/2011/06/13/implementing-a-game-center-button-in-your-corona-sdk-game/

And it goes like this (with new widget instead of old UI button…)

local widget = require( "widget" ) local function testNetworkConnection() local netConn = require('socket').connect('www.apple.com', 80) if netConn == nil then return false end netConn:close() return true end local function gotoGameCenter() local device = system.getInfo ( "environment" ) local appURL = "gamecenter:" if device == "simulator" then print ( "Cannot spawn this URL in the simulator" ) else if testNetworkConnection() then system.openURL ( appURL ) end end end local myButton = widget.newButton { left = 100, top = 200, width = 150, height = 50, id = "button\_1", label = "GameCenter", onEvent = gotoGameCenter, }

Ahh you see.

Now you’ve nailed it!

Thanks a lot, the gamecenter: url was exactly what I was looking for! :slight_smile:

Cheers!