iOS 运行环境检测
Combo SDK 提供了检测 iOS 运行环境的能力,游戏侧可通过调用 API 获取当前设备的越狱状态及包体构建方式。
支持平台
接入前提
集成 Combo SDK v2.24.0 or later。
调用时机
此类 API 为设备端同步查询接口,不涉及网络请求,不依赖登录或初始化流程。
游戏可在启动后任意时机调用。
API
Unity SDK 通过 IOSRuntime 静态类提供 iOS 运行环境信息查询能力。
类定义
public static class IOSRuntime
{
public static bool IsJailBroken { get; }
public static string BuildType { get; }
}
属性说明
| Properties | Type | Supported Platforms | Description |
|---|---|---|---|
| IsJailBroken | bool | 当前设备是否越狱。非 iOS 平台返回 false。 | |
| BuildType | string | 当前 iOS 包体构建方式。非 iOS 平台返回 null。取值见 BuildType。 |
代码示例
Show Code
var buildType = IOSRuntime.BuildType;
if (buildType != null)
{
var isJailBroken = IOSRuntime.IsJailBroken;
// 上报到数据平台
// 示例:上报字段 is_jail_broken = isJailBroken, ios_build_type = buildType
}
else
{
// 非 iOS 平台,不支持该检测
}
BuildType
BuildType 返回当前 iOS 包体的构建方式。
| Value | Description |
|---|---|
Simulator | 模拟器运行环境。 |
Development | 开发包。 |
TestFlight | TestFlight 测试包。 |
AppStore | App Store 正式包。 |
AdHoc | Ad Hoc 包。 |
Enterprise | 企业签 In-House 包。 |
Unknown | 无法识别包体构建方式。 |
注意事项
- 平台检查:使用
BuildType前需要判断IOSRuntime.BuildType != null。返回null表示当前平台不支持 iOS 运行时环境检测。 IsJailBroken的含义:非 iOS 平台上IsJailBroken == false不能理解为环境正常,而是不支持该检测。