EnvApp 1.0.0

EnvApp 1.0.0

Alexander Gaidukov 维护。



EnvApp 1.0.0

  • 作者
  • Alexander Gaidukov

envapp-sdk-ios

CI Status Version Carthage Compatible License Platform

概述

一个 SDK,实现了 iOS 的 EnvApp 验证协议

安装

CocoaPods

CocoaPods 是 Cocoa 项目的依赖管理器。有关使用和安装说明,请访问他们的网站。要使用 CocoaPods 将 envapp-sdk-ios 集成到您的 Xcode 项目中,请在您的 Podfile 中指定它

pod 'EnvApp', '~> 1.0.0'

Carthage

Carthage 是一个去中心化的依赖管理器,它构建您的依赖关系并为您提供二进制框架。要使用 Carthage 将 envapp-sdk-ios 集成到您的 Xcode 项目中,请在您的 Cartfile 中指定它。

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

Swift 包管理器

Swift 包管理器是一个用于自动分发 Swift 代码的工具,并集成到 swift 编译器中。

一旦您设置了 Swift 包,添加 envapp-sdk-ios 作为依赖就像将其添加到 Package.swiftdependencies 的值一样简单。

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

如何使用

将带有您的公钥的 PublicKey.pem 文件添加到应用程序包。

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) {

    }
}

要求

  • iOS 10.0+

许可

envapp-sdk-ios 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。