How do I build a game that only supports Game Center if it's available on the iPhone?

StackOverflow https://stackoverflow.com/questions/3990035

  •  10-10-2019
  •  | 
  •  

سؤال

I'm about to begin building an iPhone game that will make use of Game Center Achievements and high scores, but I'd also like to have a version that works on iPhones that don't have Game Center (i.e. iOS version < 4.1). Can I have two versions of the same app in the app store, one for game center, one for without? Or should I design the app such that if the iPhone doesn't have Game Center, it won't make use of it, and if it does, it will make use of it?

I'm going to continue researching this, just thought I'd post this question and get some feedback in the meantime. Thanks so much!

هل كانت مفيدة؟

المحلول

Here's the definitive response I received from one of the Apple engineers...

"We'd recommend making one version of the app which dynamically detects whether Game Center is available and uses it (or not) based on that."

نصائح أخرى

Maybe create a game without it, then create the capabilities for the game center, but disable them, and only enable them if they have the right version.

I am doing the same thing. If you have GameCenter capabilities, you can use the features. If you don't, you can't.

I would not program a game without and then add it later. In my case I disable Multiplayer for non-GC users.

Also, you may want your game to work if the device has GC capabilities, but the user cannot, for whatever reason, connect to GC currently.

You can use the following function to detect if the device supports Game Center:

BOOL isGameCenterAvailable()
{
    // Check for presence of GKLocalPlayer API.
    Class gcClass = (NSClassFromString(@"GKLocalPlayer"));

    // The device must be running running iOS 4.1 or later.
    NSString *reqSysVer = @"4.1";
    NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
    BOOL osVersionSupported = ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending);

    return (gcClass && osVersionSupported);
}

However I found that a lot of people have not updated to iOS 4.1 or are naive about Game Center. The number of users in my game is quite small even though there are so many downloads. I was actually considering moving over to Open Feint which is very much easier to implement than Game Kit and also supports older devices.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top