Latest 0.1
Homepage https://github.com/kingschat/KingsLogin-ios
License Apache 2.0
Platforms ios 11.0, requires ARC
Authors

KingsChat For Developers

This library allows your app to login using Kingschat.
Written in Swift 4.2
Supported iOS version 11.0 and higher

Installation Guide

  1. Create your app in Kingschat Dashboard
  2. Integration

    • CocoaPods
    • Navigate to your project folder in terminal
    • Make sure you have the CocoaPods installed
    • Add pod 'KCLoginSDK' to your Podfile
    • Run the following command in your project root directory from a terminal window
      $ pod install
  3. Configure info.plist file
    • Right click info.plist, and choose Open As Source Code
    • Copy and paste the following XML snippet into the body of your file ( <dict>...</dict>).
      <key>CFBundleURLTypes</key>
      <array>
      <dict>
      <key>CFBundleURLSchemes</key>
      <array>
          <string>kc-[YOUR_CLIENT_ID]</string>
      </array>
      </dict>
      </array>
      <key>KingschatClientId</key>
      <string>[YOUR_CLIENT_ID]</string>
      <key>LSApplicationQueriesSchemes</key>
      <array>
      <string>kingschat</string>
      </array>
  4. Connect your AppDelegate

    • Set delegate
      func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
      // Initialize KingsChat login
      LoginManager.delegate = self
      return true
      }
    • Handle KingsChat URL
      func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
      let sourceAppName = options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String
      let handled = LoginManager.handle(url, sourceAppName: sourceAppName)
      return handled
      }
    • Implement KCLoginManagerDelegate
      
      extension AppDelegate: KCLoginManagerDelegate {
      func login(succeededWith response: KCLoginResponse) {
      print(response.authCode.value)
      }

    func login(failedWithError error: KCLoginError) {
    print(error.message)
    }
    }

  5. Add Kingschat login to your code
    
    import UIKit
    import KCLoginSDK

class ViewController: UIViewController {
private lazy var button: KCLoginButton = {
let button = KCLoginButton()
return button
}()

override func viewDidLoad() {
    super.viewDidLoad()
    view.addSubview(button)
}

}

Latest podspec

{
    "name": "KCLoginSDK",
    "version": "0.1",
    "summary": "Swift 4.2 Framework for authenticating with the KingsChat",
    "homepage": "https://github.com/kingschat/KingsLogin-ios",
    "license": "Apache 2.0",
    "authors": {
        "Lukasz Niedzwiedz": "[email protected]"
    },
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "4.2"
    },
    "platforms": {
        "ios": "11.0"
    },
    "source": {
        "git": "https://github.com/kingschat/KingsLogin-ios.git",
        "tag": "0.1"
    },
    "source_files": "KCLoginSDK/Sources/**/*.{swift}",
    "swift_version": "4.2",
    "resources": "KCLoginSDK/Resources/**/*.{png,jpeg,jpg,storyboard,xib,xcassets}",
    "requires_arc": true
}

Pin It on Pinterest

Share This