There is no way to detect if device is jailbroken.
Consider that even if there was, the device has already been jailbroken, meaning arbitrary code execution is possible, and the jailbreaker would just modify whatever method of detection you would use to signal that the device has not been jailbroken.
reference:
https://forums.developer.apple.com/thread/43073
credits go to Apple Staff who answered this same question