Android
- SDK 1.27 及之后版本
- SDK 1.24 ~ 1.26
- SDK 1.24 之前版本
Unity 2021 ~ Unity 6
androidx
minSdkVersion: 21
targetSdkVersion: 34
compileSdkVersion: 34
如果接入 LINE,minSdkVersion 需要升级到 24。
如果接入 Discord、DMM,minSdkVersion 需要升级到 23。
项目提审前需注意:从 SDK V1.24.00 开始,Google 新增了 foreground service permissions 权限声明。如果该声明未通过 Google 审核,重新提交审核可能需要一周左右的时间。更多信息,请参见前台服务必须定义类型。
Unity 2021 ~ Unity 2022
androidx
minSdkVersion: 21
targetSdkVersion: 34
compileSdkVersion: 34
如果接入 LINE,minSdkVersion 需要升级到 24。
如果接入 Discord、DMM,minSdkVersion 需要升级到 23。
项目提审前需注意:从 SDK V1.24.00 开始,Google 新增了 foreground service permissions 权限声明。如果该声明未通过 Google 审核,重新提交审核可能需要一周左右的时间。更多信息,请参见前台服务必须定义类型。
Unity 2018 ~ Unity 2022
- Unity 2022 及之后版本
- Unity 2022 之前版本
androidx
minSdkVersion: 19
targetSdkVersion: 34
compileSdkVersion: 34
如果接入 VK,minSdkVersion 需要 升级到 21。
androidx
minSdkVersion: 16
targetSdkVersion: 34
compileSdkVersion: 34
如果接入 LINE,minSdkVersion 需要升级到 19。
如果接入 Firebase,minSdkVersion 需要升级到 19,Android Gradle 需要升级到 V6.7.1 或以上,Android Gradle Plugin 需要升级到 V4.2.0 或以上。
如果接入 VK,minSdkVersion 需要升级到 21。
如果接入 Discord,DMM,minSdkVersion 需要升级到 23。
如果接入 Adjust,minSdkVersion 需要升级到 18。
前提条件
游戏使用的每个 SDK 插件的版本(包括游戏启 动器使用的版本)必须保持一致。如果游戏需要同时访问多个版本的 Player Network SDK,或者只有一个组件需要升级,请联系 Player Network 助手。
步骤1:安装 SDK
1. 将 Player Network SDK 添加到您的项目
- 解压 SDK 软件包。
- 将
INTLSDK
文件夹复制到项目的Assets
文件夹中。 - 将 Player Network SDK 的
Plugins
文件夹合并到项目的Plugins
文件夹中。
Player Network SDK package
├─INTLSDK // Player Network SDK CS scripts which provide APIs and callbacks
│ ├─Editor // Player Network SDK Editor scripts which include Player Network SDK XUPorter
│ └─Scripts // Player Network SDK scripts which include INTLCore and other plugin scripts
├─LevelInfinite // LI PASS APIs
├─Plugins // Player Network SDK plugins for various platforms
│ ├─Android
│ ├─iOS
│ ├─MacOS
│ └─Windows~
├─Symbols // Player Network SDK symbol table *.so files
└─UnionAdapter // UnionAdpater APIs which adapts to both MSDK and Player Network SDK
INTLSDK/Scripts/INTLCore
├─INTLSDK
│ ├─Editor
│ └─Scripts
│ ├─INTLConfig
| └─INTLCore
| ├─Editor // INTLCore PostProcess.cs / PreProcess.cs files for different platforms
| | ├─INTLCoreAndroidPostProcess.cs
| | ├─INTLCoreiOSPostProcess.cs
| | ├─INTLCoreMacOSPostProcess.cs
| | ├─INTLCoreWindowsPostProcess.cs
| | └─INTLCoreWindowsPreProcess.cs
| └─Scripts // INTLCore scripts
| ├─INTLAPI.cs // Player Network SDK APIs
| ├─INTLConfig.cs // Player Network SDK data structures
| ├─INTLDefine.cs // Player Network SDK static strings
| ├─INTLErrorCode.cs // Player Network SDK error codes
| ├─Modules
| └─Utils
├─LevelInfinite
├─Plugins
├─Symbols
└─UnionAdapter
INTLSDK/Script/INTLConfig
├─INTLSDK
│ ├─Editor
│ └─Scripts
│ ├─INTLConfig
| | └─Editor // Player Network SDK configuration files, PostProcess.cs files, and encryption tools
| | ├─Encrypt
| | | ├─decrypt // Player Network SDK decryption tool for INTLConfig.ini
| | | ├─Decrypt.exe // Player Network SDK decryption tool for INTLConfig.ini
| | | ├─encrypt // Player Network SDK encryption tool for INTLConfig.ini
| | | ├─Encrypt.exe // Player Network SDK encryption tool for INTLConfig.ini
| | | ├─EncryptConfig.ini // Player Network SDK file to enable or disable INTLConfig.ini encryption
| | | ├─INTLConfigINI.cs
| | | ├─INTLConfigINIEditor.cs
| | | └─INTLEditorTools.cs
| | ├─INTLConfigAndroidPostProcess.cs
| | ├─INTLConfigiOSPostProcess.cs
| | ├─INTLConfigMacOSPostProcess.cs
| | ├─INTLConfigSwitchPreProcess.cs
| | ├─INTLConfigWind...sPostProcess.cs
| | └─Resources // Player Network SDK configurations
| | ├─APASConfig.ini // APAS device level configuration file
| | └─INTLConfig.ini // Player Network SDK main configuration file
| └─INTLCore
├─LevelInfinite
└─Plugins
2. 加载所需的权限和插件
如果您的游戏尚未创建 Android 自定义 activity,请参见 Create a custom activity。
添加用于加载权限、库和插件的 Player Network SDK 代码至自定义启动 activity(Android 游戏会在此处请求权限和加载插件)。
为加载库添加代码
static {
try {
System.loadLibrary("INTLFoundation");
System.loadLibrary("INTLCore");
System.loadLibrary("INTLUnityAdapter");
}
catch (Exception e) {
e.printStackTrace();
}
}
注册 activity 生命周期
import com.intlgame.api.INTLSDK;
import android.content.Intent;
import android.os.Bundle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// add this line
INTLSDK.initialize(MainActivity.this);
}
@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
// add this line
INTLSDK.onNewIntent(intent);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// add this line
INTLSDK.onActivityResult(requestCode, resultCode, data);
}
@Override
public void onRequestPermissionsResult(int arg0, String[] arg1, int[] arg2) {
super.onRequestPermissionsResult(arg0, arg1, arg2);
// add this line
INTLSDK.onRequestPermissionsResult(arg0, arg1, arg2);
}
载入动态权限
通过代码获取动态权限
添加以下代码以动态申请权限:
import android.app.Activity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import java.util.ArrayList;
import java.util.List;
private void RequestPermission(Activity activity, List<String> permissionList, int requestCode) {
if (null != activity && null != permissionList) {
List<String> permissionNeeded = new ArrayList();
for (int i = 0; i < permissionList.size(); ++i) {
String permission = (String) permissionList.get(i);
if (null != permission && 0 != ContextCompat.checkSelfPermission(activity.getApplicationContext(), permission)) {
permissionNeeded.add(permission);
}
}
if (permissionNeeded.size() > 0) {
ActivityCompat.requestPermissions(activity, (String[]) permissionNeeded.toArray(new String[permissionNeeded.size()]), requestCode);
}
}
}
private void RequestDynamicPermissions() {
List<String> permissions = new ArrayList();
permissions.add("android.permission.INTERNET");
permissions.add("android.permission.READ_PHONE_STATE");
this.RequestPermission(this, permissions, 100);
}
调用 RequestDynamicPermissions
:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// add this line
RequestDynamicPermissions();
INTLSDK.initialize(MainActivity.this);
}