首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >游戏中心URL方案

游戏中心URL方案
EN

Stack Overflow用户
提问于 2011-06-03 18:57:15
回答 3查看 6.6K关注 0票数 21

可以使用以下命令从您自己的应用程序中打开游戏中心应用程序:

代码语言:javascript
运行
复制
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter:"]];

有没有办法在特定游戏的页面上打开它?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2011-11-03 16:08:47

我尝试过很多不同的组合。从iBook缺乏这样的功能,缺乏文档,以及我相信你已经发现的--互联网上缺乏信息--我想说的是,有人可能不得不暴力破解URL来找出它(如果它被设置为通过URL转到各个应用程序的话)。以下是我尝试过的一些方法:

代码语言:javascript
运行
复制
    [[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解析模式:

您需要精通正则表达式才能使用它们。以下是我为您键入的一些内容:

代码语言:javascript
运行
复制
    [[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"]];
票数 26
EN

Stack Overflow用户

发布于 2013-10-25 00:04:06

Cirrostratus的答案中使用的示例URL缺少一些内容。

代码语言:javascript
运行
复制
[[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硬编码到应用程序中。

票数 0
EN

Stack Overflow用户

发布于 2014-01-11 19:10:01

仅使用此例程。

代码语言:javascript
运行
复制
    - (void)showGameCenter
{

GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init];

    if (gameCenterController != nil)
    {
        gameCenterController.gameCenterDelegate = self;
        gameCenterController.viewState = GKGameCenterViewControllerStateDefault;       
        [self presentViewController: gameCenterController animated: YES completion:nil];

    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6226195

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档