Detect Jailbreak device iOS Swift/Objective-C
Apr 7, 2022
here is simple method to find jail breaking devices in swift.
Hopefully you checked on starting so put on starting view controller and call this function, if swift-
func DetectJailBreak() {
let url = URL(string: "cydia://package/com.example.package")
if let url = url {
if UIApplication.shared.canOpenURL(url) {
let alert = UIAlertController(title: "Jailbroke Device found!!!", message: "This app can't be run in a Jailbroken device", preferredStyle: .alert)
DispatchQueue.main.async(execute: { [self] in
present(alert, animated: true)
})
return
}
}
Objective -C
-(void)DetectJailBreak
{
NSURL *url = [NSURL URLWithString:@"cydia://package/com.example.package"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Jailbroke Device found!!!" message:@"This app can't be run in a Jailbroken device"preferredStyle:UIAlertControllerStyleAlert];
dispatch_async(dispatch_get_main_queue(), ^{
[self presentViewController:alert animated:YES completion:nil];
});
return;
}
}
Thank you!