可以使用以下命令从您自己的应用程序中打开游戏中心应用程序:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter:"]];
有没有办法在特定游戏的页面上打开它?
发布于 2011-11-03 16:08:47
我尝试过很多不同的组合。从iBook缺乏这样的功能,缺乏文档,以及我相信你已经发现的--互联网上缺乏信息--我想说的是,有人可能不得不暴力破解URL来找出它(如果它被设置为通过URL转到各个应用程序的话)。以下是我尝试过的一些方法:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter:id350536422"]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter:us/app/cheese-moon/id350536422"]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter:games/"]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter:350536422"]];
更新
我梳理了操作系统的内部结构,找出了Game Center的URL解析模式:
您需要精通正则表达式才能使用它们。以下是我为您键入的一些内容:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter:/me/account"]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter:/me/signout"]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter:/friends/recommendations"]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter:/games/recommendations"]];
发布于 2013-10-25 00:04:06
Cirrostratus的答案中使用的示例URL缺少一些内容。
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter://static.gc.apple.com/me/"]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter://static.gc.apple.com/friends/"]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter://static.gc.apple.com/games/"]];
这些网址似乎适合我在iOS 6和7上使用。我假设如果你登录到沙盒游戏中心帐户,你将不得不使用sandbox.gc.apple.com。我试图通过/games/game/<id>/
和/friends/player/<id>/
访问某个特定的游戏或好友页面,但我尝试的ID似乎都不起作用。对于朋友URL,我转到一个空白的朋友页面。
即使有人发现了这一点,因为这是没有记录的,苹果可能会在未来的任何时候改变,所以我不会将这样的URL硬编码到应用程序中。
发布于 2014-01-11 19:10:01
仅使用此例程。
- (void)showGameCenter
{
GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init];
if (gameCenterController != nil)
{
gameCenterController.gameCenterDelegate = self;
gameCenterController.viewState = GKGameCenterViewControllerStateDefault;
[self presentViewController: gameCenterController animated: YES completion:nil];
}
}
https://stackoverflow.com/questions/6226195
复制相似问题