Emil
Emil

Reputation: 126

Switch directly to the Game Center app

I have a method that checks if the player is signed in to Game Center or not. If not I would like to bring up an alert view with a button that directly takes them to the Game Center app to sign in. Is this possible in any way?

Upvotes: 2

Views: 1040

Answers (2)

一二三
一二三

Reputation: 21249

Rather than forcing the user to switch between applications, Apple recommends that you show the Game Centre UI within your own application. This involves setting the authenticateHandler property or calling authenticateWithCompletionHandler on the GKLocalPlayer object, as described in the Game Center Programming Guide.

Upvotes: 0

iPhoneProcessor
iPhoneProcessor

Reputation: 5110

Just open gamecenter URL on button tap.

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter:"]];

Also put handle url in app delegate:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    return YES;
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    return YES;
}

Upvotes: 3

Related Questions