brytescore-ios
brytescore-ios是一个开源iOS SDK,可以将您的网站与Brytescore API连接起来。Brytescore API允许您跟踪用户的行为并评分他们的参与度。
示例
要运行示例项目,首先克隆仓库,然后从Example目录运行pod install
安装
brytescore-ios可以通过CocoaPods获取。要安装它,只需将以下行添加到Podfile中即可
pod "BrytescoreAPI"
Objective-C
将Objective-C项目导入时,请在Podfile的顶部为您的目标包含以下内容。
use_frameworks!
导入BrytescoreAPI
Swift
import BrytescoreAPI
Objective-C
@import BrytescoreAPI;
方法
初始化
设置API密钥。生成一个新的唯一会话ID。检索任何保存的用户ID。
- 参数 {string} API密钥。
Swift
let _apiManager = BrytescoreAPIManager(apiKey: "<api-key>")
Objective-C
BrytescoreAPIManager *apiManager = [[BrytescoreAPIManager alloc] initWithApiKey: @"<api-key>"];
getAPIKey
返回当前API密钥
- 返回值:当前的API密钥
Swift
_apiManager.getAPIKey()
Objective-C
[apiManager getAPIKey];
load
加载json包的函数。
- 参数 {string} 包名。
Swift
_apiManager.load(package: "realestate")
Objective-C
[apiManager loadWithPackage:@"realestate"];
devMode
设置开发模式。将事件记录到控制台而不是发送到API。开启开发模式会自动触发调试模式。
- 参数 enabled:如果为true,则开启开发模式。
Swift
_apiManager.devMode(enabled: devMode)
Objective-C
[apiManager devModeWithEnabled: devMode];
debugMode
设置调试模式。当调试模式关闭时,将抑制日志事件。
- 参数 enabled:如果为 true,则启用调试模式。
Swift
_apiManager.debugMode(enabled: debugMode)
Objective-C
[apiManager debugModeWithEnabled: debugMode];
impersonationMode
设置模拟模式。在模拟其他用户时跳过向 API 发送信息。
- 参数 enabled:如果为 true,则启用模拟模式。
Swift
_apiManager.impersonationMode(enabled: impersonationMode)
Objective-C
[apiManager impersonationModeWithEnabled: impersonationMode];
validationMode
设置验证模式。为所有API调用中的数据添加验证属性。
- 参数 enabled:如果为true,则启用验证模式。
Swift
_apiManager.validationMode(enabled: validationMode)
Objective-C
[apiManager validationModeWithEnabled: validationMode];
brytescore
开始跟踪特定于已加载包的属性。
- 参数 property:属性名称
- 参数 data:属性跟踪数据
Swift
_apiManager.brytescore(property: propertyName, data: propertyData)
Objective-C
[apiManager brytescoreWithProperty: propertyName data: propertyData];
页面浏览
开始页面浏览。
- 参数数据:页面浏览的数据。
- data.isImpersonating
- data.pageUrl
- data.pageTitle
- data.referrer
Swift
_apiManager.pageView(data: [:])
Objective-C
[apiManager pageViewWithData: [NSDictionary dictionary]];
已注册账户
发送新的账户注册事件。
- 参数数据:注册数据。
- data.isImpersonating
- data.userAccount.id
Swift
_apiManager.registeredAccount(data: registrationData)
Objective-C
[apiManager registeredAccountWithData: registrationData];
表单提交
发送表单提交事件。
- 参数数据:聊天数据。
- data.isImpersonating
Swift
_apiManager.submittedForm(data: submittedFormData)
Objective-C
[apiManager submittedFormWithData: submittedFormData];
startedChat
发送 startedChat 事件。
- 参数数据:表单数据。
- data.isImpersonating
Swift
_apiManager.startedChat(data: startedChatData)
Objective-C
[apiManager startedChartWithData: startedChatData];
updatedUserInfo
更新用户的账户信息。
- 参数数据:账户数据。
Swift
_apiManager.updatedUserInfo(data: updatedUserInfoData)
Objective-C
[apiManager updatedUserInfoWithData: updatedUserInfoData];
已认证
发送用户认证事件。
- 参数数据:认证数据。
- data.isImpersonating
- data.userAccount
- data.userAccount.id
Swift
_apiManager.authenticated(data: authenticatedData)
Objective-C
[apiManager authenticatedWithData: authenticatedData];
killSession
终止会话。
Swift
_apiManager.killSession()
Objective-C
[apiManager killSession];