> For the complete documentation index, see [llms.txt](https://tyson.gitbook.io/vigamedoc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tyson.gitbook.io/vigamedoc/cn/ke-hu-duan-jie-ru/ye-wu-jie-kou/1.-ji-chu-neng-li.md).

# 1.基础能力

## 1.1 初始化(必接)

### Android

```java
CoreNative.init();
```

### iOS

```objectivec
[IOSLoader application:application DidFinishLaunchingWithOptions:launchOptions];
```

## 1.2 设置退出响应代码（仅限Android）

### Android（必接）

```java
PayNative.setGameExitCallback(Runnable runnable);
```

示例：

```java
PayNative.setGameExitCallback(new Runnable() {

    @Override
    public void run() {
        // TODO Auto-generated method stub
        CoreNative.gameExit();//该方法必须调用
        currentActivity.finish();
        System.exit(0);
    }
});
```

参数:

* runnable：退出执行的代码

## 1.3 调用退出（Android必接）

### Android

```java
PayNative.openExitGame();
```

因游戏有自己的退出界面，建议按照如下方法判断：

```java
if(PayNative.isExitGame()){
    //通过调用下面的方法弹出渠道的退出
    PayNative.openExitGame();
}
else{
    //这里弹出引擎的退出界面
    ...
}
```

### Unity

```csharp
Wb.PayManager.Instance.OpenExitGame();
```

示例：

```csharp
if (Wb.PayManager.Instance.IsSupportExit())
{
    //如果支持退出，则调用openExitGame接口
    Wb.PayManager.Instance.OpenExitGame();
}
else {
    //否则展示引擎的退出窗口
    showEngineExit();
}
```

### Creator

```csharp
Wb.Tool.applicationExit();
```

## 1.4 获取应用参数

### Android

```java
import com.google.extra.platform.Utils;

//获取应用名称
Utils.getAppName();
//获取包名
Utils.get_package_name();
//获取渠道名
Utils.getChannel();
//获取项目ID
Utils.get_prjid();
//获取app版本
Utils.get_app_ver();
//获取imei
Utils.get_imei();
//获取网络状态 (0-无网络 1-手机网络 2-wifi网络 3-以太网络 4-蓝牙网络)
Utils.get_net_state();
```

### iOS

```objectivec
//获取应用名称
[IOSLoader getAppName];
//获取包名
[IOSLoader getPackageName];
//获取渠道名
[IOSLoader getChannel];
//获取项目ID
[IOSLoader getPrjId];
//获取app版本
[IOSLoader getAppVersion];
//获取imei
[IOSLoader getImei];
//获取网络状态(0-无网络 1-手机网络 2-wifi网络 3-以太网络 4-蓝牙网络)
[IOSLoader getNetState];
```

### Unity

```csharp
//获取包名
Wb.CoreManager.Instance.GetPackageName();
//获取渠道名
Wb.CoreManager.Instance.GetChannel();
//获取项目ID
Wb.CoreManager.Instance.GetPrjid();
//获取app版本
Wb.CoreManager.Instance.GetVerName();
//获取imei
Wb.CoreManager.Instance.GetImei();
//获取网络状态(0-无网络 1-手机网络 2-wifi网络 3-以太网络 4-蓝牙网络)
Wb.CoreManager.Instance.GetNetState();
```

### Creator

```csharp
let pname = Wb.Core.getPackageName();//获取包名
let prjid = Wb.Core.getPrjid();//获取项目ID
let imsi = Wb.Core.getImsi();//获取imsi
let imei = Wb.Core.getImei();//获取imei
let lsn = Wb.Core.getLsn();//获取lsn
let appid = Wb.Core.getAppid();//获取appid
let channel = Wb.Core.getChannel();//获取渠道名
let vername = Wb.Core.getVerName();//获取app版本
let result = Wb.Core.getAuditSwitch();//获取审核开关，返回值：0-未审核 1-审核中
let state = Wb.Core.getNetState();//获取网络状态(0-无网络 1-手机网络 2-wifi网络 3-以太网络 4-蓝牙网络)
```

## 1.5 获取自定义开关

### Android

```java
ChnlManager.getValueForKey(String customKey);
```

示例：

```java
//获取审核开关，返回值：0-未审核 1-审核中
ChnlManager.getValueForKey("audit");
```

### iOS

```
+ (NSString *)selfDefineSwitch:(NSString *)customKey;
```

示例：

```
[IOSLoader selfDefineSwitch:@"audit"]
```

### Unity

```
Wb.CoreManager.Instance.GetCustomSwitch(string customKey)
```

示例：

```
Wb.CoreManager.Instance.GetCustomSwitch("audit")
```

参数：

* customKey：自定义键值

返回值：1-审核中 0-过审

### Creator

```
Wb.Core.getCustomSwitch(customKey:string);
```

示例：

```
Wb.Core.getCustomSwitch("audit")
```

参数：

* customKey：自定义键值

返回值：1-审核中 0-过审


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tyson.gitbook.io/vigamedoc/cn/ke-hu-duan-jie-ru/ye-wu-jie-kou/1.-ji-chu-neng-li.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
