1

AppSync causes some problems with iCloud and in-app-purchasing, so I'd like to detect does it exist on device to handle weird behaviour of iCloud and IAP. Is there any way to know this?

Nevermind if device is jailbroken, but AppSync prevents my app from working properly, moreover it is obviously "a trace of hack".

4

1 に答える 1

1

I've searched and found traces of AppSync, here is the code to find out whether it exists on device. Yes, it's a little longer than needed but I wanted to be sure. Of course in release code you should obfuscate strings somehow, but that's it:

bool isAppSyncExist()
{
    BOOL isbash = NO;
    BOOL isappsync = NO;
    FILE *f = fopen("/bin/bash", "r");
    if (f != NULL)
    {
        //Device is jailbroken
        isbash = YES;
        fclose(f);
    }

    if (isbash)
    {
        f = fopen("/Library/MobileSubstrate/DynamicLibraries/AppSync.plist", "r");
        if (f != NULL)
        {
            isappsync = YES;
            fclose(f);
        }
        if (isappsync == NO)
        {
            NSError *err;
            NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@"/private/var/lib/dpkg/info" error:&err];

            for (int i = 0; i < files.count; i++)
            {
                NSString *fname = [files objectAtIndex:i];
                if ([fname rangeOfString:@"appsync" options:NSCaseInsensitiveSearch].location != NSNotFound)
                {
                    isappsync = YES;
                    break;
                }
            }
        }
        if (isappsync == NO)
        {
            NSError *err;
            NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@"/var/lib/dpkg/info" error:&err];

            for (int i = 0; i < files.count; i++)
            {
                NSString *fname = [files objectAtIndex:i];
                if ([fname rangeOfString:@"appsync" options:NSCaseInsensitiveSearch].location != NSNotFound)
                {
                    isappsync = YES;
                    break;
                }
            }
        }
    }

    return isappsync == YES;
}
于 2012-10-25T22:29:08.863 に答える