I recently upgraded to Xcode 8 and converted my code to Swift 3. I am making a custom keyboard (extension) which worked perfectly fine till iOS 9, but i am facing a couple of issues in iOS 10.
Issue: This button click is not working in iOS 10 i.e the user is not directed to the settings. I have configured the URL Schemes in my project and have tried the following code :
@IBAction func btnGetStarted(_ sender: AnyObject) {
let settingsUrl = URL(string: UIApplicationOpenSettingsURLString)
if let url = settingsUrl {
UIApplication.shared.openURL(url)
}
}
Also tried :
@IBAction func btnGetStarted(_ sender: AnyObject) {
if let settingsURL = URL(string:"prefs:root=General&path=Keyboard/KEYBOARDS") {
UIApplication.shared.openURL(settingsURL)
}
}
Issue: This toast does not pop up when the app is run in iOS 10
Code of the toast:
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath){
let pbWrapped: UIPasteboard? = UIPasteboard.general
if let pb = pbWrapped {
if currentKeyboard == XXXXXX.emoji {
if let data = UIImagePNGRepresentation(dataEmoji[(indexPath as NSIndexPath).row]) {
pb.setData(data, forPasteboardType: "public.png")
self.makeToast(pasteMessage, duration: 3.0, position: .center)
}
}
} else {
var style = ToastStyle()
style.messageColor = UIColor.red
style.messageAlignment = .center
//style.backgroundColor = UIColor.whiteColor()
self.makeToast("To really enjoy the keyboard, please Allow Full Access in the settings application.", duration: 8.0, position: .center, title: nil, image: UIImage(named: "toast.png"), style: style, completion: nil)
}
}
I did check out few solutions on stackoverflow but none of them worked for me, as I said before my app works perfectly fine on all versions except iOS 10. Please can someone help me out?
Swift 3 iOS 10
let settingsUrl = NSURL(string:UIApplicationOpenSettingsURLString) as! URL
UIApplication.shared.open(settingsUrl, options: [:], completionHandler: nil)
@persianBlue: This is working on Xcode8 + iOS10.
UIApplication.shared.openURL(URL(string:UIApplicationOpenSettingsURLString)!)
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