views:

573

answers:

2

This is my current set up for my multiplayer game:

A view that gives connection tips and warns the user that multiplayer will not work on the 1st Gen iPhone or ipod Touch. There is a "connect" button that pushes the game view and starts the GKPeerPicker.

Unfortunately, I don't have a 1st Gen iPhone or iPod Touch to test what happens if they press the connect button. The view will be pushed, but I don't know what will happen when the PeerPicker tries to show.

So the Question(s):

Is there anyway to tell if the user will not be able to use GameKit so that I can disable the "connect" button?

What will happen if they do press the connect button and GameKit is not available?

+1  A: 

You could find out what model of iPhone or iPod Touch your application is running on, and then disable the function if it is not an accepted iPhone/iPod type.

To do this, you could add the following to your application:

#import <sys/utsname.h>

- (NSString *) machineModel {
    struct utsname systemInfo;
    uname (&systemInfo);
    return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
}

Calling NSLog(@"Type: %@", [self machineModel]) will give you the hardware model.

Alex Reynolds
I ended up using this to throw an alert if the user is using an 1st gen iPhone or iPod Touch.
Reese McLean
+1  A: 

If you totally don't want the app running at all on unsupported hardware, use the peer-peer value as a member of the UIRequiredDeviceCapabilities key in your Info.plist. I'm pretty sure you can also set this with iTunes Connect when you submit your app. More info in the Device Support section of the iPhone Application Programming guide.

Of course, if your app can use wifi as well as Bluetooth, then you don't want to do this, since you actually can run on 1st gen iPhones and touches.

invalidname