Как запустить приложение iphone GameCenter из моего приложения?

Я думаю, что лучший и, возможно, единственный способ — это использовать схемы URL с [[UIApplication sharedApplication] openURL:...]. Но я не могу найти схему URL для игрового центра.


person Ruslan Konyshev    schedule 18.04.2011    source источник


Ответы (3)


Вы можете запустить приложение Game Center, используя схему URL-адреса gamecenter::

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter:"]];
person Nick Forge    schedule 26.04.2011

В iOS 6.0 появился новый способ показать Game Center с помощью GKGameCenterViewController.

Для его использования ваш контроллер представления должен действовать как делегат GKGameCenterViewController:

@interface ViewController : UIViewController <GKGameCenterControllerDelegate>

А затем для отображения представления Game Center:

- (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];
}

Если пользователь находится под iOS 5.0, вы можете использовать только схемы URL, как вы сказали ранее.

person gergonzalez    schedule 05.10.2012

Попробуйте пример кода Apple. Это объясняет, как ваше приложение работает с игровым центром. http://developer.apple.com/library/ios/#samplecode/GKTapper/Introduction/Intro.html

person Helge Becker    schedule 18.04.2011
comment
это не то, что мне нужно, я знаю, как работать с игровым центром, но мой клиент хочет иметь возможность перенаправить пользователя из своего приложения прямо в приложение GameCenter - person Ruslan Konyshev; 20.04.2011