Skip to main content

Switching from GCloud to Player Network SDK

Replace the SDK

Replace GCloud MSDK with Player Network SDK in your project directory.

  1. Remove the GCloud MSDK plugin directory from the project.

    • Remove SDK scripts. The script directory: MSDKCore, MSDKBugly, and MSDKFirebase folders under the Assets/GCloudSDK/Scripts/ directory.
    • Remove Android plugin directories: Assets/Plugins/Android/gcloudsdk-msdk-xxx directory and relative third-party plugin directories.
    • Remove Android resource files: MSDKConfig.ini, MSDKRetMsg.json, MSDKBuglyConfig.json, msdk_permission_content.html, and msdk_policy_content.html under the Assets/Plugins/Android/assets/ directory.
    • Remove GCloud MSDK related code from Android mainTemplate.gralde.
    • Remove iOS plugin directory Assets/Plugins/iOS/GCloudSDK/MSDKxxx.
  2. Integrate Player Network SDK into the project.

  3. Switch to Player Network backend service.

Client Code Adaptation

The GCloud MSDK is successfully replaced with Player Network SDK, you need to adapt client code to Player Network SDK.

Adapting to Player Network SDK

Player Network SDK provides API encapsulation for the Unity engine:

  • All interfaces are in the INTLAPI.cs file.
  • All data structure definitions are in the INTLDefine.cs file.
  • All error codes are in the INTLErrorCode.cs file.

Games only need to take note of the three scripts mentioned above, not the implementation of the internal logic.

  • Player Network SDK optimizes the interface encapsulation. For example, the naming of the interface is more direct, rarely used fields such as subChannel are removed from the login interface, and so on.
  • Player Network SDK optimizes the callback of each module. It uses INTLAPI.AddxxxObserver and INTLAPI.RemovexxxObserver methods to declare callbacks. All callbacks are defined in the INTLAPI.cs file.

The following section takes the login interface as an example to show code adaptation.

Code Sample

To implement login through MSDK, add login observer as follows:

// Declare the callback
MSDKLogin.LoginRetEvent += OnLoginRetEvent;

// Process the callback function
private void OnLoginRetEvent(MSDKLoginRet loginRet)
{
Debug.Log ("OnLoginRetNotify in Login");
// ...
}
// Call the login interface
MSDKLogin.Login(MSDKChannel.WeChat);

To implement login through Player Network SDK, add login observer as follows:

// Declare the callback
INTLAPI.AddAuthResultObserver(OnAuthResultEvent);

// Process the callback function
public void OnAuthResultEvent(INTLAuthResult ret)
{
Debug.Log ("OnAuthResultEvent in Login");
//...
}

// Call the login interface
INTLAPI.Login(INTLChannel.Facebook);

Blueprint call

Not applicable.

Replace the Backend Service

The client adaptation is done. Replace the GCloud backend service with the Player Network backend service.

Player Network SDK provides backend services in the same way as the GCloud MSDK. Games only need to change the URL.

Differences between Player Network SDK and GCloud

From the overall service perspective, Player Network SDK optimizes the design of modules and interfaces, and provides a unified service to facilitate fast business integration. The main differences are:

  • Player Network SDK provides a consistent way to manage backend data for a set of services.
  • Player Network SDK provides engine-specific adaptation and encapsulation that facilitate game integration.