Coder Social home page Coder Social logo

flicktypekit's Introduction

FlickType icon FlickType screenshot FlickType screenshot

FlickTypeKit 🚀

Build Status

“Best of 2020” - Apple
“Apple Watch App of the Year” - AppAdvice
“Makes Typing a Breeze” - Forbes

Add a powerful keyboard to your watchOS apps and dramatically improve the text input experience for users. Leverage full typing and editing capabilities to greatly enhance existing parts of your app, or enable entirely new features like messaging and note-taking directly on Apple Watch.

SwiftUI

Use a FlickTypeTextEditor to display an editable text interface and gather text input from the user:

import FlickTypeKit

struct ContentView: View {
  @State private var text = ""
  var body: some View {
    ScrollView {
      VStack {
        // other views here...
        FlickTypeTextEditor("Message", text: $text)
        // more views here...
      }
    }
  }
}

WatchKit

Modify your presentTextInputController() calls to include the flickType argument:

import FlickTypeKit

presentTextInputController(
  withSuggestions: nil,
  allowedInputMode: .allowEmoji,
  flickType: .ask) { items in
  if let text = items?.first as? String {
    print("User typed text: \(text)")
  }
}

.ask will offer a choice between FlickType and the standard input methods (recommended).
.always will always open FlickType, skipping the input method selection.
.off will present the standard input method selection without the FlickType option.

Note: When using WatchKit, the optional startingText argument can be used to support editing of existing text with FlickType. In SwiftUI, FlickTypeTextEditor does that automatically for you.

Integration

Swift Package Manager

https://github.com/FlickType/FlickTypeKit

This version of FlickTypeKit will only show FlickType as an input option to users on watchOS 7 or later. FlickTypeKit uses universal links to switch from your app to the FlickType Keyboard app, and then return the input text back to you. Thus the keyboard stays up-to-date without you having to update your app, and leverages the user's custom settings and dictionary. To support universal links in your app:

  1. Add an applinks associated domain entitlement to your watch extension target: Associated domains screenshot

  2. Create a file named apple-app-site-association (without an extension) with the following contents, and place it in your site’s .well-known directory:

{
  "applinks": {
      "details": [
           {
             "appIDs": [ "<Team ID>.your.watchkitextension.identifier" ],
             "components": [
               {
                  "/": "/flicktype/*",
                  "comment": "Matches any URL whose path starts with /flicktype/"
               }
             ]
           }
       ]
   }
}

The file’s URL should match the format https://your.app.domain/.well-known/apple-app-site-association and must be hosted with a valid certificate and with no redirects.

  1. Add the following inside your WKExtensionDelegate.applicationDidFinishLaunching():
FlickType.returnURL = URL(string: "https://your.app.domain/flicktype/")
  1. Add the following inside your WKExtensionDelegate.handle(_ userActivity: NSUserActivity):
if FlickType.handle(userActivity) { return }

Note: Always test on a real device, since the Simulator does not support app switching via universal links yet.

Help & support

  • The sample app contains implementations for both SwiftUI & WatchKit.
  • Join our Discord
  • Email us!

flicktypekit's People

Contributors

keleftheriou avatar pixlwave avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

flicktypekit's Issues

URL fetch error

Trying to incorporate FlickTypeKit into a new WatchOS 8 app.
Ive set up the Associated file infrastructure and WatchKit extension entitlement
On the Xcode Sim, I get:
LocalMetar WatchKit Extension[44255:420001] [default] Failed to open URL https://flicktype.com/type/?returnURL=https://myCompany.com/flicktype/&token=655910846.844237&startingText=: Error Domain=NSPOSIXErrorDomain Code=45 "Operation not supported" UserInfo={_LSLine=519, _LSFunction=_LSOpenOperationPerform}

Same happens on real device

FlickTypeTextEditor fails to present in a sheet

Minimal code sample to reproduce:

struct ContentView: View {
    @State var message = ""
    
    var body: some View {
        Color.blue
            .sheet(isPresented: .constant(true)) {
                FlickTypeTextEditor("Add Message", text: $message, mode: .ask, onCommit: { })
            }
    }
}

The first tap on the FlickTypeTextEditor results in the following message in the console:

2022-01-04 14:25:01.881590+0000 My WatchKit Extension[10590:118594] [Presentation] Attempt to present <PUICQuickboardRemoteViewController: 0x7fd4b3013800> on <SPHostingViewController: 0x7fd4ae811a00> (from <SPHostingViewController: 0x7fd4ae811a00>) whose view is not in the window hierarchy.

Any attempts after that all generate this message instead, irrespective of if the text editor is inside a sheet or part of the root view:

2022-01-04 14:25:11.918978+0000 My WatchKit Extension[10590:118594] Quickboard: attempting to present before the previous presentation has been cleaned up!

I haven't had the time to investigate what causes this yet.

FlickType from master and swift-5.1 branches are incompatible with Xcode 11

It appears that the framework in the master branch is not compiled for swift 5.1, and that the swift-5.1 branch is not updated to be compiled with the official release of Xcode 11, thus couldn't be included as Xcode 11 requests rebuilding the framework.

In Xcode 11, the message "Compiled module was created by an older version of the compiler; rebuild FlickTypeKit and try again" is shown.

Thanks.

Crash when using system inputs

Looks like I've introduced a bug in #6 where the app will crash when using one of the default input methods and not FlickType. It crashes on the force unwrap here, which is called from here.

I've had a look, but I'm not massively sure where to inject the completionType when FlickType wasn't selected. 😕

Add languages

Hey,
Great keyboard, helps me a lot with my Apple Watch series 5 use. As an iOS developer, I’ll be glad to make an contribution by adding support to my local language, Hebrew.
Is that possible with the code in that git?
If not, could you share the relevant code with me for that matter?
Thanks
Matan

Add VoiceOver support

It appears that there's a lack of VoiceOver support when using the FlickType SDK, whereas the official watch app supports VoiceOver just fine. This was reported by a VoiceOver user of one of my apps.

Can VoiceOver support be included in the SDK? Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.