2019-09-022 minutes read (About 244 words)How to check app running on jailbreak iOS deviceIssue #385 From https://github.com/OneSignal/OneSignal-iOS-SDK/blob/master/iOS_SDK/OneSignalSDK/Source/OneSignalJailbreakDetection.m 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172+ (BOOL)isJailbroken { #if !(TARGET_IPHONE_SIMULATOR) FILE *file = fopen("/Applications/Cydia.app", "r"); if (file) { fclose(file); return YES; } file = fopen("/Library/MobileSubstrate/MobileSubstrate.dylib", "r"); if (file) { fclose(file); return YES; } file = fopen("/bin/bash", "r"); if (file) { fclose(file); return YES; } file = fopen("/usr/sbin/sshd", "r"); if (file) { fclose(file); return YES; } file = fopen("/etc/apt", "r"); if (file) { fclose(file); return YES; } file = fopen("/usr/bin/ssh", "r"); if (file) { fclose(file); return YES; } NSFileManager *fileManager = [NSFileManager defaultManager]; if ([fileManager fileExistsAtPath:@"/Applications/Cydia.app"]) return YES; else if ([fileManager fileExistsAtPath:@"/Library/MobileSubstrate/MobileSubstrate.dylib"]) return YES; else if ([fileManager fileExistsAtPath:@"/bin/bash"]) return YES; else if ([fileManager fileExistsAtPath:@"/usr/sbin/sshd"]) return YES; else if ([fileManager fileExistsAtPath:@"/etc/apt"]) return YES; else if ([fileManager fileExistsAtPath:@"/usr/bin/ssh"]) return YES; // Omit logic below since they show warnings in the device log on iOS 9 devices. if (NSFoundationVersionNumber > 1144.17) // NSFoundationVersionNumber_iOS_8_4 return NO; // Check if the app can access outside of its sandbox NSError *error = nil; NSString *string = @"."; [string writeToFile:@"/private/jailbreak.txt" atomically:YES encoding:NSUTF8StringEncoding error:&error]; if (!error) return YES; else [fileManager removeItemAtPath:@"/private/jailbreak.txt" error:nil]; // Check if the app can open a Cydia's URL scheme if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"cydia://package/com.example.package"]]) return YES; #endif return NO;}#iOS