Home > OS >  Check if Apple LiveText is available?
Check if Apple LiveText is available?

Time:03-16

I want to add apple live text support using a scan button. But I know that it is available for iOS 15 and A12 processors and above. How do I check that in Swift?

CodePudding user response:

Don't check for the iOS 15 and processor A12 , check for the iOS 15's 'Live Text'feature support. Create a helper method with the following check that will return whether the device support live text or not


Sample:

var isSupported = true
if #available(iOS 15.0, *) {
    let check = UITextField().canPerformAction(#selector(UIResponder.captureTextFromCamera(_:)), withSender: nil)
    isSupported = check
} else {
    isSupported = false
}

print(isSupported)

Using the above condition will return false in the case of the device having iOS 15 but not having hardware support.

  • Related