SSOLibClaysol
安装
CocoaPods
CocoaPods 是 Cocoa 项目的依赖管理器。有关使用和安装说明,请访问他们的网站。要使用 CocoaPods 将 SSOLibClaysol 集成到您的 Xcode 项目中,请在 Podfile 中指定它
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target '<Your Target Name>' do
pod 'SSOLibClaysol'
end
使用
import SSOLibClaysol
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
func application(_ app: UIApplication, open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if let scheme = url.scheme,
scheme.localizedCaseInsensitiveCompare("com.ssoSampleApp") == .orderedSame {
var parameters = [String: String]()
URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems?.forEach {
parameters[$0.name] = $0.value
}
//Key will be different for each cp.
let key128 = "MTIzRTREQzk4RjI1NTc1OEIxMDZGMkEyNTBBRDQ0QkI="
do {
let aes = try ClaysolSSO(keyString: key128)
if let userInfo = parameters["data"] {
let decryptedData = try aes.decrypt(userInfo)
// In case if decryptedData come nil please check private key provided by Claysol.
let alertController = UIAlertController(title: nil, message: decryptedData, preferredStyle:UIAlertController.Style.alert)
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default)
{ action -> Void in
// Put your code here
})
self.window?.rootViewController?.present(alertController, animated: true, completion: nil)
}
} catch {
print("Something went wrong: \(error)")
}
}
return true
}
}