Latest 2.0.1
Homepage https://github.com/matrix-io/matrix-auth-swift-sdk
License MIT
Platforms ios 8.0, osx 10.10, watchos 2.0, tvos 9.0
Dependencies Alamofire, JSONWebToken, Result

MATRIX Swift Auth SDK

MATRIX Authentication framework for Swift

Build Status
CocoaPods Compatible
License
Platform
Swift

Requirements

  • iOS 8.0+
  • Xcode 8.1, 8.2, 8.3, 9.0
  • Swift 3.0, 3.1, 3.2, 4.0

Installation

CocoaPods

To integrate MATRIX Auth SDK into your Xcode project using CocoaPods, specify it in your Podfile:

    pod 'MatrixAuthSDK'

Then, run the following command:

$ pod install

Usage

The starting point is MatrixAuth. With it you can:

  • Authenticate an existing user and work with it via UserAuth
  • Create a new user with given credentials and a role
  • Request a password reset for a user, which they can then do via email

User Authentication

let auth = try MatrixAuth(clientId: ..., clientSecret: ...)
let username = "[email protected]"
let password = ...

auth.authenticate(username: username, password: password) { result in
    switch result {
    case let .success(user):
        // Do stuff with user
        ...
    case let .failure(error):
        // Authentication failure; handle error
        ...
    }
}

User Details

let user: UserAuth = ...

user.details { result in
    switch result {
    case let .success(details):
        // Prints the details of the user as returned by the AdMobilize API
        print(details)
    case let .failure(error):
        // Handle error
        ...
    }
}

User Device Secret

let user: UserAuth = ...
let device: String = ...

user.deviceSecret(for: device) { result in
    switch result {
    case let .success(secret):
        // Prints the secret for `device` belonging to `user`
        print(secret)
    case let .failure(error):
        // Handle error
        ...
    }
}

User Registration

let auth: MatrixAuth = ...

auth.registerNewUser(username: ..., password: ..., role: ...) { result in
    switch result {
    case let .success(value):
        // Do stuff with API response
        ...
    case let .failure(error):
        // Handle error
        ...
    }
}

User Password Reset

After this, an email will be sent to the user asking them to reset their
password.

let auth: MatrixAuth = ...

auth.forgotPassword(username: ...) { result in
    switch result {
    case let .success(value):
        // Do stuff with API response
        ...
    case let .failure(error):
        // Handle error
        ...
    }
}

License

This project is released under the MIT License.

Latest podspec

{
    "name": "MatrixAuthSDK",
    "version": "2.0.1",
    "summary": "MATRIX Auth SDK for Swift.",
    "homepage": "https://github.com/matrix-io/matrix-auth-swift-sdk",
    "license": {
        "type": "MIT",
        "file": "LICENSE.md"
    },
    "authors": "MATRIX Labs",
    "social_media_url": "https://twitter.com/MATRIX_Creator",
    "platforms": {
        "ios": "8.0",
        "osx": "10.10",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "source": {
        "git": "https://github.com/matrix-io/matrix-auth-swift-sdk.git",
        "tag": "v2.0.1"
    },
    "source_files": "Sources/**/*.swift",
    "dependencies": {
        "Alamofire": [
            "~> 4"
        ],
        "JSONWebToken": [
            "~> 2"
        ],
        "Result": [
            "~> 3"
        ]
    },
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This