RTamSDK 0.1.13

RTamSDK 0.1.13

Yen Phan维护。



RTamSDK 0.1.13

  • RTamSDK, Inc.

RTAMSDK

Version
Platform

分析框架

前提条件

  • 目标 iOS 11.0 或更高版本
  • 目标 tvOS 12.0 或更高版本
  • Swift 版本 5.0 或更高

安装

CocoadPods (首选)

要使用此 Pod,请按照以下步骤在您的 Xcode 项目中操作

  1. 打开您的 Podfile
  2. 向其中添加以下代码
pod 'RTAMSDK'
  1. 在您的终端中运行 pod install

Swift 包

要使用此 Swift 包在您的 Xcode 项目中,请按照以下步骤

  1. 在 Xcode 中打开您的项目。
  2. 转到文件 > Swift 包 > 添加包依赖
  3. 输入此存储库的 URL https://github.com/RTAMTECH/rtam_sdk_ios 并点击下一步。
  4. 选择您想要使用的版本规则(例如“向上至下一个主要版本”)并点击下一步。
  5. 选择您想添加包的目标并点击完成。
  6. 在您的 Swift 文件中导入 RTAMSDK 模块,您想要使用 SDK 的位置。
import RTAMSDK
  1. 现在您已经准备好在您的应用中使用 SDK 了!

初始化

您需要将以下代码添加到您的 Info.plist 文件中,并将 FILL_YOUR_WRITE_KEY_HERE 替换为您的写入密钥

<key>RTAMSDKConfig</key>
<dict>
  <key>writeKey</key>
    <string>FILL_YOUR_WRITE_KEY_HERE</string>
</dict>

在您的 UIApplicationDelegate 中导入 RTAMSDK 模块

import RTAMSDK

在您的应用代理的 application(_:didFinishLaunchingWithOptions:) 方法中配置 RTAMSDK 共享实例

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.

    RTAM.start()


    return true
}

用法

分析

分析将自动初始化并为您收集数据。您也可以使用以下方法手动跟踪事件

跟踪事件

RTAM.track(name: "Event name", properties: [String : Any]?)

您可以将任何自定义属性跟踪任何事情

struct UserLoggedInEventProperties: Codable {
    var username: String
    var mail: String
}

let userLoggedInEventProperties = UserLoggedInEventProperties(
    username: "tester",
    mail: "[email protected]"
)

RTAM.track(name: "User LoggedIn", properties: userLoggedInEventProperties)

识别事件

RTAM.identify(userId: "UserID")

如果您需要添加更多信息的情况

struct UserTraits: Codable {
    var name: String
    var birthday: String
    var phoneNumber: String
}

let traits = UserTraits(
    name: "Tester",
    birthday: "20/12/2022",
    phoneNumber: "+84909090909"
)

RTAM.identify(userId: "UserID", traits: traits)

屏幕事件

RTAM.screen(title: "LoginScreen")

属性是描述屏幕的额外信息。它们可以是您想要的任何内容。

struct ScreenProperties: Codable {
    var name: String
    var loginMethod: String
}

let properties = ScreenProperties(
    name: "Login",
    loginMethod: "Apple ID"
)

RTAM.screen(title: "LoginScreen", properties: properties)

许可证

RTAMSDK 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。