You can detect if a device is jailBroken or not by checking the following
- Cydia is installed
- Verify some of the system paths
- Can perform a sandbox integrity check
- Perform symlink verification
- Verify whether you create and write files outside your Sandbox
There is an open source library I created from various articles and books, try it out.