Revolt iOS
库是用Swift编写的。专为跟踪事件而设计,使用标准JSON格式、可编码对象或甚至仅仅是字典。
最低部署目标:iOS 12.0
Revolt的安装
更新
版本号 | 更新内容 |
---|---|
1.0.0 | Revolt SDK发布啦!! |
1.0.1 | 修复了一些小问题 |
1.0.2 | 支持Xcode 10、Swift 4.2 |
1.0.3 | 支持屏幕跟踪,修复bug |
1.0.4 | 修复发送旧版本事件的问题 |
1.0.5 | 添加与GMT差异有关的zoneOffset |
1.0.6 | 修复SDK版本,并利用事件 |
1.0.7 | 支持Swift 5 |
1.0.8 | 支持Xcode 11 |
1.0.9 | Swift 5.x的更新 |
1.0.10 | 修复bitcode设置 |
1.0.11 | 修复模拟器构建问题 |
1.0.12 | Xcode 12、Swift 5.3的更新 |
1.0.13 | Xcode 12,目标版本12.0的更新 |
安装
Cocoa Pods
苹果项目中的 CocoaPods 是一个依赖管理系统。如果您还没有配置 CocoaPods,请查阅他们网站上的安装文档(https://guides.cocoapods.org.cn/using/getting-started.html)。如果您使用其他依赖管理系统或不想实现,请联系我们获取备选方案。
安装完 CocoaPods 后,进入应用程序根目录下的 Podfile 文件。在该文件中添加以下行
use_frameworks!
target :XXXXX do
pod 'Revolt'
end
其中 XXXXX 是您的应用程序目标名称
pod install
如果您遇到权限问题,请确保 GitHub 用户名步骤已成功完成。如有任何其他步骤问题,请参阅 Cocoapods 文档。如果您的进程在“分析依赖项”环节停止,请尝试运行 pod repo remove master,然后执行 pod setup,最后再次执行 pod install。
开启/关闭 Revolt
使用 trackingId 和密钥开启 Revolt
要在启动 Revolt(最好是您的 AppDelegate 的 didFinishLaunchingWithOptions 方法中)使用以下方法
import Revolt
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Revolt.setup(trackingId: "your_tracking_id", secretId: "your_secret_id", serviceAddress: "your_service_address")
return true
}
当您想吃止发送事件时。了解这个框架将离线收集事件是非常重要的。
Revolt.start()
Revolt.stop()
屏幕跟踪
我们已经实现了屏幕跟踪,默认是开启的
Revolt.screenTracking(enabled: true)
Revolt.screenTracking(enabled: false)
日志级别
您可以随时更改日志级别,默认设置为 warning
Revolt.setLog(level: .debug)
发送事件
所有事件都是异步发送,优先级最低。发送1000个自定义事件也没有风险。我们创建了几种下面描述的事件类型。
事件类型
- 自定义
- 带有 Codable 对象
struct UserCustom: Codable {
let firstName: String
let lastName: String
let values: [Int]
}
let variable = UserCustom(firstName: "user_firstname", lastName: "user_lastname", values: [0, 1])
Revolt.sendEventCustom(event: Revolt.EventCustomType<UserCustom>.codable(object: variable), name: "user.custom")
- 带有 JSONSerialization.data
let data = try! JSONSerialization.data(withJSONObject: ["t2": 5, "t3": 5.21], options: .prettyPrinted)
Revolt.sendEventCustom(event: Revolt.EventCustomType<UserCustom>.json(data: data), name: "user.custom")
- 使用字典
Revolt.sendEventCustom(event: Revolt.EventCustomType<UserCustom>.raw(dictionary: ["parameter1": 1, "parameter2": "value2"]), name: "user.custom")
- Profile
Revolt.send(event: .profile(appUserId: "appUserId", birthYear: 2018, gender: .male, country: "Poland", city: "Krakow"))
- SignIn
Revolt.send(event: .signIn(appUserId: "appUserId"))
- SignOut
Revolt.send(event: .signOut(appUserId: "appUserId"))