Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to programmatically detect Game Center?
    primarykey
    data
    text
    <p>I'm adding Game Center support to my game. Because my game can run on iOS versions back to 3.0, I want to have it fallback to just saving achievements and leaderboards locally in the absence of Game Center.</p> <p>Right now, I have this:</p> <pre><code>+ (BOOL) isGameCenterAvailable { Class playerClass = NSClassFromString( @"GKLocalPlayer" ); if( playerClass != nil &amp;&amp; [playerClass localPlayer] != nil ) { DebugLog( @"Game Center is available" ); return YES; } DebugLog( @"Game Center is NOT available" ); return NO; } </code></pre> <p>However, this appears not to work at all. For one thing, despite the <a href="http://developer.apple.com/library/ios/#documentation/GameKit/Reference/GKLocalPlayer_Ref/Reference/Reference.html%23//apple_ref/doc/uid/TP40009587" rel="nofollow noreferrer">GKLocalPlayer reference</a> stating that this class is available in iOS 4.1 and higher, the above test passes in iOS 4.0 (I didn't try earlier versions). For another thing, the test also passes on devices which have iOS 4.1, but which otherwise don't support Game Center (for example, an iPhone 3G). </p> <p>I've gone through the various GameKit and Game Center docs online, and haven't had any luck figuring this out. I could certainly detect the OS version, but that seems lame. That also wouldn't help for the case of unsupported hardware (like a 3G). That could also be detected I suppose, but again, seems kinda lame.</p> <p>What's the "right way" to programmatically detect Game Center support?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload