Screen time restriction on safari misleading the canOpenURL function

Viewed 48

I have one module in which I used to check URL is valid or not via canOpenUrl() all things working smooth but one of my testers put a screen time restriction on safari from Setting -> screen time -> content & privacy restriction -> allow app -> disable safari.

Now canOpenUrl() return false every time so is there any way we can find a restriction on safari?

    if UIApplication.shared.canOpenURL(urlWeb) {
                
                        let arrComponent = URLComponents(string: urlWeb.absoluteString)?.path.components(separatedBy: "/")
                        if arrComponent?.contains(where: { (strElement) -> Bool in
                            return strElement == "test"
                        }) == true , let nativeUUID = arrComponent?.last {
             } 
        } else {
print("Not valid URL")
    }
1 Answers

Do not use canOpenURL for this code. This code will have the same behavior and same results, even if you skip the canOpenURL check.

Related