0

How to check the “Allow Full Access” is enabled in iOS 11?

I have tried multiple methods which do not seem to be working in iOS 10 or iOS 11.

Here is one that I tried:

func hasFullAccess() -> Bool
{
    var hasFullAccess = false
    if #available(iOSApplicationExtension 10.0, *) {
        let pasty = UIPasteboard.general
        if pasty.hasURLs || pasty.hasColors || pasty.hasStrings || pasty.hasImages {
            hasFullAccess = true
        } else {
            pasty.string = "TEST"
            if pasty.hasStrings {
                hasFullAccess = true
                pasty.string = ""
            }
        }
    } else {
        // Fallback on earlier versions
        var clippy : UIPasteboard?
        clippy = UIPasteboard.general
        if clippy != nil {
            hasFullAccess = true
        }
    }
    return hasFullAccess
}

Every time it returns true and I am running this on a device not on the simulator.

Niall Kiddle
  • 1,477
  • 1
  • 16
  • 35

1 Answers1

-1

First of all, it feels like you're checking the iOS version wrong. It usually looks like this if #available(iOS 11.0, *) where iOS version you pass is the latest one you use. In your declaration iOS 11 is not even there, it checks for iOS 10 and below.

Second, you're using || which is OR operator. So if any of those statements is true, the whole thing will return true. You need && the AND operator to check whether everything is matching.

inokey
  • 5,434
  • 4
  • 21
  • 33