How to detect whether custom keyboard is activated from the keyboard's container app?

前端 未结 4 1013
清酒与你
清酒与你 2020-12-01 03:13

I was wondering if there is a method that would allow me to detect from the keyboard container app whether the associated keyboard has been activated in the

4条回答
  •  天涯浪人
    2020-12-01 03:41

    You can use this function (Swift 3 and 4) to check your custom keyboard extension have open access or not:

    func isOpenAccessGranted() -> Bool{
        if #available(iOS 10.0, *) {
           let originalString = UIPasteboard.general.string
           UIPasteboard.general.string = "Sour LeangChhean"
    
           if UIPasteboard.general.hasStrings {
    
               UIPasteboard.general.string = originalString ?? ""
               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
           }
       }
    }
    

提交回复
热议问题