How do I detect that an iOS app is running on a jailbroken phone?

后端 未结 17 1551
情书的邮戳
情书的邮戳 2020-11-22 10:48

If I want my app to behave differently on a jailbroken iPhone, how would I go about determining this?

17条回答
  •  无人共我
    2020-11-22 11:35

    BOOL isJailbroken()
    {
    #if TARGET_IPHONE_SIMULATOR
        return NO;
    #else
        FILE *f = fopen("/bin/bash", "r");
    
        if (errno == ENOENT)
        {
            // device is NOT jailbroken
            fclose(f);
            return NO;
        }
        else {
            // device IS jailbroken
            fclose(f);
            return YES;
        }
    #endif
    }
    

提交回复
热议问题