supersdk

文档中心

文档中心

下载文档

Preparation before integration (Unity)


Before integrating, please make sure you have downloaded the latest version of SuperSDK4.0+Demo (Unity version).](http://www.supersdk.cn/download.html)。

Unity configuration

Import SuperSDKForUnity.unitypackage

Screenshot

When the Unity project imports the package, the path cannot contain Chinese characters.

SuperSDK For Unity internally relies on the LitJson library, and if the game itself has been introduced, there is no need to introduce it.

Add SuperSDKGObject.perfabe

Screenshot

In the scene that needs to receive the callback, add the Perfabe or set the Perfabe not to be destroyed when the scene is switched, otherwise no callback event will be received.

Note: The game developer can also add the SuperSDK_BindCallBack.cs script to a gameObject that it will never destroy.

Android configuration

Modify AndroidManifest (required)

Add android:name=“com.supersdk.openapi.SuperSdkApplication” to the application node and add the appropriate configuration under the application node:

<application
        android:allowBackup="true"
        android:label="SuperSDKDemo" 
        # 添加下面这个值即可
        android:name="com.supersdk.openapi.SuperSdkApplication" >
        
        # 添加相应配置
        <meta-data
            android:name="sp_version"
            android:value="4.0.6" >
        </meta-data>
        <activity
            android:name="com.supersdk.demo.platform.sdk.PluginLoginActivity"
            android:screenOrientation="sensor"
            android:theme="@android:style/Theme.Dialog" />
</application >

Add corresponding permissions:

<!-- 统计所需权限 -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

Import SuperSDK head files

import com.yz.unity.YzSDK;
import com.supersdk.openapi.SuperSDK;

iOS configuration

Add SuperSdk version number

In the project’s info.plist file, add a value to identify the SuperSDK version number. The key is sp_version, and the corresponding value is the version of currently connected SuperSdk.framework.

Screenshot

For the version number of SuperSDK.framework, please see the README.txt in downloaded documents. Screenshot

Add system dependencies

Add dependency libraries in Xcode -> Target -> Build Phrases -> Link Binary WithLibraries:

Foundation.framework
UIKit.framework
AdSupport.framework
SystemConfiguration.framework
CoreTelephony.framework
libstdc++.6.tbd
libsqlite3.tbd

(Note: Change the status of AdSupport.framework to optional)

Modify the project configuration, add the link parameters of the library

In the project configuration, find the Linking section, modify the Other Linker Flags, and add -ObjC.

Screenshot

Import SuperSDK head files

#import "SuperSdkWrapper.h"//接口

Interface Description

##Add an orginal package configuration file##

Download the orginal package configuration from the packaging tool and add (replace) to the assets directory, as shown below Screenshot

initialization

Interface description: Invoking this interface will initialize each module of SuperSDK, iOS and Android side invoke, the initialization result will return to the callback event registered by Unity.

The Android initialization interface must be invoked synchronously in onCreate, otherwise it will affect the login and payment functions of some channels.

The iOS initialization interface must be called inside didFinishLaunchingWithOptions.

The initialization interface has been specially processed. If the initialization is over, the Unity callback has not been registered yet. Android and iOS will wait for the callback to register and then callback. Game developer does not need to worry.

Interface invoke:

//Unity端初始化接口,在游戏永不销毁的预设体start生命周期调用
SuperSDK.getInstance().Init(this.gameObject.name,new SuperSDK_CallBack());  //SuperSDK_CallBack类需实现ICallBackManager接口
//Android 初始化接口,放在java端调用,必须在onCreate里面同步调用
YzSDK.init(this)
//iOS 初始化接口,放在iOS端调用,必须在didFinishLaunchingWithOptions里面调用
[SuperSdkWrapper init];
/// <summary>
/// 基础CallBack接口
/// </summary>
public void OnCallBack(string moduleName, string funcName, string result)
{
    Debug.Log("moduleName:" + moduleName);
    Debug.Log("funcName:" + funcName);
    Debug.Log("result:" + result);

    JsonData resultData = JsonMapper.ToObject(result);

    // 平台模块回调
    if (moduleName.Equals(SuperSDKPlatform.MODULE_NAME)) 
    {
        if(funcName.Equals(SuperSDKPlatform.FUNC_INIT))
        {
            if ((int)resultData["code"] == SuperSDKConstants.SUCCESS)
            {
                //初始化成功
            }
            else
            {
                //初始化失败,必须重启游戏
            }
        }
    }
}

Callback log printing:

moduleName:platform
funcName:init
result:
{
    "code":1,
    "msg":"没有更新接口"
}

Integrated lifecycle interface

Interface description: The lifecycle interface must be called synchronously in the corresponding method of the game’s main activity.

@Override
protected void onStart() {
    super.onStart();
    SuperSDK.lifecycle.onStart();
}

protected void onResume() {
    super.onResume();
    SuperSDK.lifecycle.onResume();
};

@Override
protected void onPause() {
    super.onPause();
    SuperSDK.lifecycle.onPause();
}

@Override
protected void onStop() {
    super.onStop();
    SuperSDK.lifecycle.onStop();
}

@Override
protected void onRestart() {
    super.onRestart();
    SuperSDK.lifecycle.onRestart();
}

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    SuperSDK.lifecycle.onNewIntent(intent);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    SuperSDK.lifecycle.onActivityResult(requestCode, resultCode, data);
}

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    SuperSDK.lifecycle.onSaveInstanceState(outState);
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    SuperSDK.lifecycle.onConfigurationChanged(newConfig);
}

@Override
protected void onDestroy() {
    super.onDestroy();
    SuperSDK.lifecycle.onDestroy();
}

Appendix

如下表所示:

String constant Actual string Description
平台模块常量
SuperSDKPlatform.MODULE_NAME platform Module name, fixed per module constant name
SuperSDKPlatform.FUNC_SHOW_LOGO showLog Whether to display a splash screen
SuperSDKPlatform.FUNC_INIT init initialization
SuperSDKPlatform.FUNC_LOGIN login log in
SuperSDKPlatform.FUNC_HAS_LOGOUT hasLogout Whether the channel has a logout interface
SuperSDKPlatform.FUNC_LOGOUT logout Logout
SuperSDKPlatform.FUNC_PAY pay Pay
SuperSDKPlatform.FUNC_PAY_ORDER_ID payOrderId Successfully get pay order ID
SuperSDKPlatform.FUNC_EXIT exit exit the game
SuperSDKPlatform.FUNC_ENTER_GAME enterGame enter the game
SuperSDKPlatform.FUNC_CREATE_ROLE createRole Creating a Role
SuperSDKPlatform.FUNC_LEVEL_UP levelUp Role levelup
SuperSDKPlatform.FUNC_HAS_FORUM hasForum Determine if there is a forum
SuperSDKPlatform.FUNC_OPEN_FORUM openForum Open forum
SuperSDKPlatform.FUNC_HAS_USER_CENTER hasUserCenter Determine if there is a user center
SuperSDKPlatform.FUNC_OPEN_USER_CENTER openUserCenter Open the user center
SuperSDKPlatform.FUNC_HAS_CUSOMER_SERVICE hasCustomerService Determine if there is customer service
SuperSDKPlatform.FUNC_OPEN_CUSOMER_SERVICE openCustomerService Open customer service
SuperSDKPlatform.FUNC_OPEN_LOGIN_PAGE openLoginPage open login page
SuperSDKPlatform.FUNC_OPEN_HOME_PAGE openHomePage open homepage
SuperSDKPlatform.FUNC_HAS_GUEST hasGuest Whether the user is a guest
SuperSDKPlatform.FUNC_GUEST_UPGRADE guestUpgrade guest upgrade
SuperSDKPlatform.FUNC_OTHER_FUNCTION otherFunction Extension interface other
Statistical module constant
SuperSDKStats.MODULE_NAME stats Module name
SuperSDKStats.FUNC_REPORT report Statistical reporting
Tool module constant
SuperSDKTools.MODULE_NAME tools Module name
SuperSDKTools.FUNC_GET_IPINFO getClientIPInfo Obtain client IP information, such as ip area
SuperSDKTools.FUNC_GET_LANGUAGE getLanguage Get the local system language
SuperSDKTools.FUNC_GET_COUNTRY getCountry Get local country regions
SuperSDKTools.FUNC_COPY_TOCLIPBOARD copyToClipboard Copy text to clipboard
SuperSDKTools.FUNC_ALERT alert alert
SuperSDKTools.FUNC_GET_PACKAGE_NAME getPackageName Get the application package name
SuperSDKTools.FUNC_GET_VERSION_NAME getVersionName Get the versionName under AndroidManifest
SuperSDKTools.FUNC_GET_VERSION_CODE getVersionCode Get the versionCode under AndroidManifest
SuperSDKTools.FUNC_GET_META_DATA getMetaData Get the value of the meta-data under AndroidManifest
SuperSDKTools.FUNC_SET_SCREEN_LIGHT setScreenLight Adjust screen light
SuperSDKTools.FUNC_SAVE_DATA saveData save data
SuperSDKTools.FUNC_GET_DATA getData Get saved data
SuperSDKTools.FUNC_GET_DEVICE_ID getDeviceId Get device ID
Configuration module constant
SuperSDKConfig.MODULE_NAME config Module name
SuperSDKConfig.FUNC_GET_VALUE getValue Get configuration information
Advertising module constant
SuperSDKAdVert.MODULE_NAME advert Module name
SuperSDKAdVert.FUNC_TRACK track Activate ad
Yoozoo module constant
SuperSDKForYZ.MODULE_NAME youzu Module name
SuperSDKForYZ.FUNC_GET_VALUE getValue Get configuration, such as opid, opgameid