Latest 0.3.0
Homepage https://github.com/safx/TypetalkKit
License MIT
Platforms ios 8.4, osx 10.10, requires ARC
Dependencies APIKit, Starscream
Authors

TravisCI
codecov.io
Platform
License
Version
Carthage

TypetalkKit is an unofficial web API client for Typetalk.

Basic Usage

The following code gets user’s topics and prints these.

TypetalkAPI.sendRequest(GetTopics()) { result in
    switch result {
    case .Success(let ts):
        for i in ts {
            print(i)
        }
    case .Failure(let error):
        // error
    }
}

TypetalkKit supports almost all Typetalk API.

If you want to know further information about API, please visit official page.

Features

  • Pure Swift API
  • Full REST API support with APIKit
  • Streaming API support with Starscream

Authorization

To use TypetalkKit, you need to register your app at the Official Developer page first.

When you register your app, choose "Authorization Code" for Grant Type and set URI including custom URL scheme,
which should be unique to complete authorization process.

In your app, set developer settings:

TypetalkAPI.setDeveloperSettings(
    clientId:     "Your ClientID",
    clientSecret: "Your SecretID",
    redirectURI:  "Your custome scheme",    // e.g. typetalkkit+<YOUR_APP_ID>://auth/success
    scopes: [Scope.my, Scope.topic_read])

And then call authorize.

TypetalkAPI.authorize { (error) -> Void in
   ...
}

TypetalkKit use Safari for Typetalk’s authorization process.
You, thearefore, have to add a custom URL scheme for "redirect URI" to your Info.plist in order to switch back to your app from Safari.

When your app is back from Safari, call TypetalkAPI.authorizationDone in your application(openURL, sourceApplication, annotation) as follows:

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
    if TypetalkAPI.isRedirectURL(url) && sourceApplication? == "com.apple.mobilesafari" {
        return TypetalkAPI.authorizationDone(URL: url)
    }
    return false
}

If you don’t call authorizationDone, the callback of authorize never be called.

In OS X, you can use TypetalkAPI.authorizationDone in handleGetURLEvent as follows:

func handleGetURLEvent(event: NSAppleEventDescriptor?, replyEvent: NSAppleEventDescriptor?) {
    if let ev = event,
        url_str = ev.descriptorForKeyword(AEKeyword(keyDirectObject))?.stringValue,
        url = NSURL(string: url_str) where TypetalkAPI.isRedirectURL(url) {
            TypetalkAPI.authorizationDone(URL: url)
    }
}

For more information of Typetalk’s authorization, please see official page.

Install

CocoaPods

pod 'TypetalkKit'

Carthage

github "safx/TypetalkKit" ~> 0.3.0

Manual Install

  1. Add TypetalkKit as a submodule:

    git submodule add https://github.com/safx/TypetalkKit.git
  2. Add TypetalkKit.xcodeproj to your project.
  3. Add TypetalkKit to "Target Dependencies" of "Build Phases" tab of your app’s target.
  4. Add "Copy Files" to copy TypetalkKit.framework:
    1. Click "+" button, and select "New Copy Files Phase" to add "Copy Files" to choose.
    2. Set the "Destination" to "Frameworks", and add TypetalkKit.framework.

Latest podspec

{
    "name": "TypetalkKit",
    "version": "0.3.0",
    "summary": "An unofficial web API client for Typetalk, a web service for team disscussions.",
    "homepage": "https://github.com/safx/TypetalkKit",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "MATSUMOTO Yuji": "[email protected]"
    },
    "source": {
        "git": "https://github.com/safx/TypetalkKit.git",
        "tag": "0.3.0"
    },
    "source_files": "Source/**/*.swift",
    "platforms": {
        "ios": "8.4",
        "osx": "10.10"
    },
    "dependencies": {
        "APIKit": [
            "~> 1.1.1"
        ],
        "Starscream": [
            "~> 1.0.2"
        ]
    },
    "requires_arc": true
}

Pin It on Pinterest

Share This