Check whether the iPhone is jailbroken.

Source: Internet
Author: User

 

How can I check whether a jailbreak exists? The easiest way is to check whether your device has a directory for jailbreak. The following is the code.

 

Detectdevice. h

 

View plaincopy to clipboardprint?
  1. @ Interface uidevice (helper)
  2. -(Bool) isjailbroken;
  3. @ End

@ Interface uidevice (helper)-(bool) isjailbroken; @ end 

Detectdevice. m

View plaincopy to clipboardprint?
  1. @ Implementation uidevice (helper)
  2. -(Bool) isjailbroken {
  3. Bool jailbroken = no;
  4. Nsstring * cydiapath = @ "/applications/cydia. app ";
  5. Nsstring * aptpath = @ "/private/var/lib/APT /";
  6. If ([[nsfilemanager defaultmanager] fileexistsatpath: cydiapath]) {
  7. Jailbroken = yes;
  8. }
  9. If ([[nsfilemanager defaultmanager] fileexistsatpath: aptpath]) {
  10. Jailbroken = yes;
  11. }
  12. Return jailbroken;
  13. }
  14. @ End

@ Implementation uidevice (helper)-(bool) isjailbroken {bool jailbroken = no; nsstring * cydiapath = @ "/applications/cydia. APP "; nsstring * aptpath = @"/private/var/lib/APT/"; if ([[nsfilemanager defaultmanager] fileexistsatpath: cydiapath]) {jailbroken = yes ;} if ([[nsfilemanager defaultmanager] fileexistsatpath: aptpath]) {jailbroken = yes;} return jailbroken;} @ end 

 

Then, call [uidevice currentdevice] isjailbroken] in your code. If yes is returned, the code is cracked. If no is returned, the Code is not cracked.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.