OnLaunch

OnLaunch iOS 客户端

Swift Versions

kula.app 和所有优秀的贡献者创建并维护。

OnLaunch 是一项允许应用程序开发者通知应用用户关于更新、警告和维护的服务。我们的开源框架提供了一个易于集成的客户端,用于与后端通信并显示用户界面。

OnLaunch iOS

特性

安装

您可以使用 Swift Package Manager 将 OnLaunch 集成到您的项目中。

  1. 在 Xcode 中,转到 File --> Swift Packages --> Add Package Dependency
  2. 粘贴软件包仓库 URL:https://github.com/kula-app/OnLaunch-iOS-Client
  3. 选择所需的版本或分支(例如,main 为最新的开发版本)。
  4. 选择您要添加 OnLaunch 的目标。
  5. 点击 Finish 完成集成。

用法

使用 SwiftUI 构建的应用

  1. OnLaunch iOS 客户端导入到您的 App 文件中
import OnLaunch
  1. 在您的根内容 View 上应用配置视图修饰符以设置您的公钥
@main
struct MainApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .configureOnLaunch { options in
                    // Configure the public key to authenticate with the API endpoint
                    options.publicKey = "<YOUR PUBLIC APP KEY>"
                }
        }
    }
}
  1. 可以选择通过修改 options 来配置 OnLaunch 客户端
...
.configureOnLaunch { options in
    // Configure the public key to authenticate with the API endpoint
    options.publicKey = "<YOUR PUBLIC APP KEY>"

    // (Optional) Configure a custom base URL to your API host
    // options.baseURL = "https://your-domain.com/api"
}
...

使用 UIKit 构建的应用

  1. OnLaunch iOS 客户端导入到您的 SceneDelegate 文件中
import OnLaunch
  1. 使用您的公钥配置客户端并设置 hostScene
func sceneDidBecomeActive(_ scene: UIScene) {
    OnLaunch.configure { options in
        // Configure the public key to authenticate with the API endpoint
        options.publicKey = "K2UX4fVPFyixVaeLn8Fky_uWhjMr-frADqKqpOCZW2c"

        // Configure the host scene to present the UI
        options.hostScene = scene
        // or: configure the host view controller to present the UI
        // options.hostViewController = (scene as? UIWindowScene)?.keyWindow?.rootViewController
    }
}
  1. 可以选择通过修改 options 来配置 OnLaunch 客户端
...
.configureOnLaunch { options in
    // Configure the public key to authenticate with the API endpoint
    options.publicKey = "<YOUR PUBLIC APP KEY>"

    // (Optional) Configure a custom base URL to your API host
    // options.baseURL = "https://your-domain.com/api"
}
...

如果您的应用不使用场景,您也可以在 AppDelegate 中配置 OnLaunch。

选项

OnLaunch iOS 客户端提供了一些配置选项

名称 描述 默认值
baseURL OnLaunch API 托管的基本 URL。 更改此设置以指向您自托管的 OnLaunch 服务器实例。 https://api.onlaunch.app/api/
publicKey 用于向 API 验证身份的公钥
shouldCheckOnConfigure 一个标志,指示客户端是否应在配置后立即检查新消息。 true
hostScene 用于托管 OnLaunch 客户端 UI 的场景。 如果您将 UIKit 与场景一起使用,则为必需
hostViewController 用于托管 OnLaunch 客户端 UI 的 UIViewController 实例。 如果您将 UIKit 与不使用场景,则为必需
theme OnLaunch 客户端 UI 使用的自定义主题。 调整这些值以更改主题以匹配您的偏好。 要查看所有可能的配置值,请参阅 Theme.swift Theme.swiftTheme.standard 中定义的默认值 Theme.swift
bundleId 服务器端规则使用的捆绑包标识符。 使用 Bundle.main.bundleIdentifier 中设置的值
bundleVersion 标识捆绑包迭代的构建版本。 Info.plist 中定义的 CFBundleVersion
releaseVersion 捆绑包的发布版本或版本号。 Info.plist 中定义的 CFBundleShortVersionString
appStoreId 应用在 App Store 中的 ID。 如果未定义,则 ActionType.openInAppStore 将抛出非崩溃断言

贡献指南

请参阅我们的贡献指南

许可证

MIT 许可证下分发