简体   繁体   中英

Monotouch Tell Difference Between iPad 3G and WiFi (Check for GPS)

I currently have some objective C code which I use to identify the difference between an iPad 3G and an iPad WiFi. Bizarrely both models come under the device code iPad1,1 (iPad 2s have three different codes iPad2,1 iPad2,2 and iPad2,3 which allows you to tell the difference).

So the code I use to tell the difference between iPad 1st Gen models, checks for presence of the GPS functionality using the following code:

void *libHandle = dlopen(GRAPHICS_SERVICES_PATH, RTLD_LAZY);
int (*GSSystemHasCapability)(NSString *);
GSSystemHasCapability = dlsym(libHandle, "GSSystemHasCapability");
BOOL result = GSSystemHasCapability(@"gps");
dlclose(libHandle);

Being quite new to Monotouch I am unsure how to port this across. Does anyone have any pointers as to how to port this (or any other way to tell the difference)?

Bizarrely both models come under the device code iPad1,1 (iPad 2s have three different codes iPad2,1 iPad2,2 and iPad2,3 which allows you to tell the difference).

Yes, when downloading updates there's always a single binary for the first generation iPad.

So the code I use to tell the difference between iPad 1st Gen models, checks for presence of the GPS functionality using the following code:

Be warned that the above ObjectiveC code will likely be rejected by Apple if you wish your application to be available in the AppStore. That's because the feature you're looking at is part of a private framework.

#define GRAPHICS_SERVICES_PATH  "/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices"

If you want to use this (eg a non-AppStore application) then you should be able to p/invoke into the function using:

using System.Runtime.InteropServices;

...

[DllImport ("/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices")]
static extern bool GSSystemHasCapability (IntPtr value);

...

bool HasGPS ()
{
    using (NSString gps = new NSString ("gps"))
        return GSSystemHasCapability (gps.Handle);
}

UPDATE It seems the only (valid for AppStore) way to detect the GPS is to use the location services and query it's accuracy. See: How can I tell if an iOS device has a GPS?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM