How to launch iphone GameCenter application from my application?

I think the best way and possibly the only way is to use URL schemes with [[UIApplication sharedApplication] openURL: ...]. But I can not find the URL scheme for the game center.

+6
source share
3 answers

You can launch the Game Center application using the gamecenter: URL gamecenter: :

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

In iOS 6.0, the new way is pretty cool to show Game Center using the GKGameCenterViewController .

To use it, your view controller must act as a delegate to the GKGameCenterViewController:

 @interface ViewController : UIViewController <GKGameCenterControllerDelegate> 

And then to display 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 is under iOS 5.0, you can only use URL schemes, as you said earlier.

+6
source

Try the sample Apple code. This explains how your application works with gamecenter. http://developer.apple.com/library/ios/#samplecode/GKTapper/Introduction/Intro.html

-3
source

Source: https://habr.com/ru/post/886135/


All Articles