Ruslan Konyshev
Ruslan Konyshev

Reputation: 135

How to run iphone GameCenter app from my app?

I think the best way and may be only way is using the URL schemes with [[UIApplication sharedApplication] openURL:...]. But I can't find URL scheme for game center..

Upvotes: 6

Views: 4971

Answers (3)

gergonzalez
gergonzalez

Reputation: 2488

In iOS 6.0 there's a new way quite cool to show Game Center using GKGameCenterViewController.

For using it your view controller must acts as a delegate to the GKGameCenterViewController:

@interface ViewController : UIViewController <GKGameCenterControllerDelegate>

And then for displaying the Game Center view:

- (void)showGameCenter
{
    GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init];
    if (gameCenterController != nil)
    {
        gameCenterController.gameCenterDelegate = self;
        [self presentViewController: gameCenterController animated: YES completion:nil];
    }
}

//Called when the player is done interacting with the GKGameCenterViewController
- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

If the user it's under iOS 5.0, you can only use the URL schemes like you said before.

Upvotes: 6

Nick Forge
Nick Forge

Reputation: 21464

You can launch the Game Center app by using the gamecenter: URL scheme:

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

Upvotes: 16

Helge Becker
Helge Becker

Reputation: 3253

Try the Apple example code. It explain how your app work with gamecenter. http://developer.apple.com/library/ios/#samplecode/GKTapper/Introduction/Intro.html

Upvotes: -3

Related Questions