DispatchSDK 1.0.3

DispatchSDK 1.0.3

Stephen SilberYesh 维护。



  • Dispatch Solutions, Inc

DispatchSDK

GitHub tag (latest SemVer)

示例

要运行示例项目,克隆此仓库,并从 Example 目录打开 Example.xcworkspace。

要求

iOS 15.0+

安装

Swift 包管理器

使用 Swift 包管理器将以下内容添加到您的项目。在 Xcode 中

转到文件 > Swift 包 > 添加包依赖... 输入包的 URL:https://github.com/iex-xyz/dispatch-ios-sdk.git 点击下一步,选择您想要使用的版本。 点击下一步,选择您想要使用 SDK 的目标。 点击完成。

Cocoapods

将以下行添加到您的 Podfile 中

pod 'DispatchSDK'

然后运行 pod install。

设置

  1. 在 AppDelegate 中导入 DispatchSDK 模块

import DispatchSDK

  1. 在 AppDelegate 的 application(_:didFinishLaunchingWithOptions:) 方法中配置 SDK
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    let config = DispatchConfig(
        applicationId: "YOUR_APPLICATION_ID", 
        environment: .demo, // Use .production for release
        merchantId: "YOUR_MERCHANT_ID"
    )
    DispatchSDK.shared.setup(using: config)
    return true
}
  1. 将 "YOUR_APPLICATION_ID" 和 "YOUR_MERCHANT_ID" 替换为您实际的值。

  2. 在任何地方显示 SDK

DispatchSDK.shared.present(with: .checkout(id: "DISTRIBUTION_ID"))

将 "DISTRIBUTION_ID" 替换为您要显示的实际分发 ID。

  1. (可选)注册分析事件
DispatchSDK.shared.registerForEvents { event in
    print("Received event: \(event)")
}

配置

DispatchConfig

DispatchConfig 是用于设置 SDK 的配置对象。它有以下属性

  • applicationId: String - 您的应用程序 ID
  • environment: AppEnvironment - 使用环境 (.demo 或 .production)
  • merchantId: String - 您的商户 ID
  • orderCompletionCTA: String - 订单完成屏幕的号召行动文本(默认为 "继续购物")
  • hideOrderCompletionCTA: Bool - 是否隐藏订单完成号召行动(默认为 false)
  • hideRootCloseButton: Bool - 是否隐藏根视图控制器中的关闭按钮(默认为 false)

作者

Dispatch Solutions

许可证

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