2012-10-25 49 views
1

AppSync会导致iCloud和应用内购买问题,所以我想检测它是否存在于设备上以处理iCloud和IAP的奇怪行为。有什么办法可以知道吗?如何检测AppSync是否安装在设备上?

如果设备是越狱,但是AppSync阻止我的应用正常工作,而且它显然是“一丝黑客”,从来没有想过。

回答

1

我搜索了一下,发现了AppSync的痕迹,下面是代码来确定它是否存在于设备上。是的,这比需要的时间稍长一点,但我想确定。当然,在发布代码中,您应该以某种方式混淆字符串,但这就是:

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; 
} 
相关问题