TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Apr 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by zhuimiao.
To run the example project, clone the repo, and run pod install
from the Example directory first.
ios9.0 swift3.0
HHParams is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "HHParams"
let carriername = HHParams.carriername()
print("获取运营商名称:\(carriername)")
let client_v = HHParams.client_v()
print("获取客户端版本号:\(client_v)")
let phoneUserName = HHParams.phoneUserName()
print("获取手机用户名称:\(phoneUserName)")
let osversion = HHParams.osversion()
print("获取ios版本号:\(osversion)")```
* 手机型号
```swift
let phoneModel = HHParams.phoneModel()
print("获取手机型号:\(phoneModel)")
let idfa = HHParams.getIDFA()
print("广告商id:\(idfa)")
let idfv = HHParams.getIDFV()
print("供应商id:\(idfv)")
用 UserDefault 存储敏感信息,是不安全的 好在 ios 为我们提供了更安全的工具:钥匙串。很多 APP 用钥匙串存储敏感信息,比如用户的密码,银行卡信息等。
//创建钥匙串管理对象
let tool = HHKeyChain()
//设置服务名称
tool.serviceName = "loginService"
//设置 key ,value
let key = "username"
let value = "password"
// 保存 value 到 KeyChain
tool .hh_setValue(value, key)
// 从 KeyChain 读取 value
let keyChainPassword:String = tool.hh_valueForKey(key)
print("从 KeyChain 中获取的登录密码:\(keyChainPassword)")
iOS 设备唯一标示符(udid)有两种方案
缺陷:
解决方案:
st=>start: 开始
e=>end: 结束
e1=>end: 结束
op=>operation: 从钥匙串里查找udid
op1=>operation: 获取 App udid
op2=>operation: 存储到钥匙串
cond=>condition: 找到?
st->op->cond
cond(yes)->e
cond(no)->op1->op2->e1
let tool = HHKeyChain()
tool.serviceName = "udidService"
// 保存 广告商id
var idfa:String = ""
let idfaKey = "idfa"
idfa = tool.hh_valueForKey(idfaKey)
if idfa == "" {
idfa = HHParams.getIDFA()
tool.hh_setValue(idfa, idfaKey)
}
print("广告商id为:\(idfa)")
钥匙串可以分组共享数据。
要求:
步骤:
let tool = HHKeyChain()
tool.serviceName = "shareDataService"
tool.accessGroup = "574C886U7L.org.boitx.mimamiao"
let groupShareDataKey = "ShareDataKey"
let groupShareDataValue = tool.hh_valueForKey(groupShareDataKey)
print("groupShareDataValue:\(groupShareDataValue)")
zhuimiao, [email protected]
HHParams is available under the MIT license. See the LICENSE file for more info.