EnvApp 1.0.0

EnvApp 1.0.0

Maintained by Alexander Gaidukov.



EnvApp 1.0.0

  • By
  • Alexander Gaidukov

envapp-sdk-ios

CI Status Version Carthage Compatible License Platform

Overview

An SDK which implmenents EnvApp validation protocol for iOS

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate envapp-sdk-ios into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'EnvApp', '~> 1.0.0'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate envapp-sdk-ios into your Xcode project using Carthage, specify it in your Cartfile:

github "trickstersio/envapp-sdk-ios" "1.0.0"

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding envapp-sdk-ios as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/trickstersio/envapp-sdk-ios.git", from: "1.0.0")
]

How to use

Add PublicKey.pem file with your public key to the application bundle.

import EnvApp
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        if let url = launchOptions?[.url] as? URL {
            if !urlRequiresSignature(url) || validateURLSignature(url) {
                handleAppLink(url)
            } else {
                print("App link has incorrect signature")
            }
        }
    }

    private func validateURLSignature(_ url: URL) -> Bool {
        do {
            let publicKey = try PublicKey(pemNamed:"PublicKey", in: .main)
            return EnvAppValidator.validateSignatureOf(url: url, publicKey: publicKey)
        } catch {
            print(error.localizedDescription)
            return false
        }
    }

    private func urlRequiresSignature(_ url: URL) -> Bool {
        // Check if the app link requires signature or not
    }

    private func handleAppLink(_ url: URL) {

    }
}

Requirements

  • iOS 10.0+

License

envapp-sdk-ios is available under the MIT license. See the LICENSE file for more info.