Game Center URL scheme

前端 未结 3 1703
难免孤独
难免孤独 2020-12-25 13:45

It\'s possible to open the Game Center app from your own app using:

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


        
3条回答
  •  [愿得一人]
    2020-12-25 14:05

    The example URLs used in Cirrostratus's answer are missing a few bits.

    [[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/"]];
    

    These URLs seem to work for me on iOS 6 and 7. I'm assuming if you were signed into a sandbox Game Center account that you'd have to use sandbox.gc.apple.com instead. I tried to go to a specific game or friend page via /games/game// and /friends/player// but anything I try for ID doesn't seem to work. For the friends URL I go to a blank friend page.

    Even if someone did figure it out, because it's undocumented Apple could change at any time in the future so I wouldn't hardcode a URL like this into an app.

提交回复
热议问题