I'm offering a custom keyboard app. I am checking'full access' with the code below to activate some functions. It's a valuable code I discovered through this site a few years ago. But I found out that the code below doesn't run on iOS 14. UIPasteboard.general.hasStrings always returns false. hasImages/hasColors/hasURLs all return false. But it doesn't seem to be real. If you paste, there is a previously copied content or only ‘TEST’ is pasted. 'TEST' is for checking purposes and should not be printed.
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 = ""
}
}
I am deeply reflecting on what I only found out about this. Also, I'm really sorry for the users who use my app. So I'm asking here because I want to solve it somehow. So, if anyone knows how to fix it, I'd like to let you know.
What I have done so far Update ‘firebase’ and ‘realm’ to the latest version with ‘cocoapod’ Fix a problem after pod update Try modifying the code continuously by turning on/off Allow Full Access in iOS settings Google search…
Let me know if someone knows a better solution. Or, I'd like to give you a clue as to the cause of the problem. I hope that people who have the same problem will consider it together.
Thanks for reading this far. And I'll wait for someone's help. please.
We found the same issue. Our current solution is to use viewWillAppear instead of viewDidLoad when checking for full access.
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// We need to check fullAccess after view has appeared in order for UIPasteboard to be available.
if self.hasFullyAccess() == false {
// Do whatever.
}
}
public func hasFullyAccess() -> Bool {
var hasFullAccess = false
if #available(iOS 10.0, *) {
let pasty = UIPasteboard.general
if pasty.hasURLs || pasty.hasColors || pasty.hasStrings || pasty.hasImages {
hasFullAccess = true
} else {
// We test if we can put something in UIPasteboard, if anything we have access.
pasty.string = "TEST"
if pasty.hasStrings {
hasFullAccess = true
pasty.string = "" // Removes string from pasty again.
}
}
}
return hasFullAccess
}