Recently iOS has an update of iOS 10 & there are certain changes for developers one of the change is now we can't check allow full access the way we did previously is given below
-(BOOL)isOpenAccessGranted{
return [UIPasteboard generalPasteboard];
}
I searched the latest Developer Guide for UIPasteboard, but was unable to solve it. Did any one has a proper solution for this.
iOS11 and above is easy.
iOS10 Solution: Check all the copy-able types, if one of them is available, you have full access otherwise not.
-- Swift 4.2--
override var hasFullAccess: Bool
{
if #available(iOS 11.0, *){
return super.hasFullAccess// super is UIInputViewController.
}
if #available(iOSApplicationExtension 10.0, *){
if UIPasteboard.general.hasStrings{
return true
}
else if UIPasteboard.general.hasURLs{
return true
}
else if UIPasteboard.general.hasColors{
return true
}
else if UIPasteboard.general.hasImages{
return true
}
else // In case the pasteboard is blank
{
UIPasteboard.general.string = ""
if UIPasteboard.general.hasStrings{
return true
}else{
return false
}
}
} else{
// before iOS10
return UIPasteboard.general.isKind(of: UIPasteboard.self)
}
}
I have fixed this issue. iOS 10.0 and Swift 3.0
func isOpenAccessGranted() -> Bool {
if #available(iOSApplicationExtension 10.0, *) {
UIPasteboard.general.string = "TEST"
if UIPasteboard.general.hasStrings {
// Enable string-related control...
UIPasteboard.general.string = ""
return true
}
else
{
UIPasteboard.general.string = ""
return false
}
} else {
// Fallback on earlier versions
if UIPasteboard.general.isKind(of: UIPasteboard.self) {
return true
}else
{
return false
}
}
}
Use like this:-
if (isOpenAccessGranted())
{
print("ACCESS : ON")
}
else{
print("ACCESS : OFF")
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With