MSDK Login Token Management Guide

MSDK Login Token Management Guide

1. Overview

In this guide, we will discuss the MSDK (Mobile Social Development Kit) login token management process for Android games. The MSDK provides a set of APIs and tools to help game developers integrate social features into their games.

2. Call Back

The WGLogin() interface is used to obtain a login token. This interface does not require any parameters, and the return value is true if the login is successful.

public static boolean WGLogout();

3. Interface Declaration

The WGPlatform class provides a set of interfaces for managing social features in games. The WGLogin() interface is used to obtain a login token, while the WGGetLoginRecord() interface is used to retrieve the current login status.

WGPlatform.WGLogout();

4. Parameters

No parameters are required for the WGLogin() and WGGetLoginRecord() interfaces.

5. Return Value

The return value of the WGLogin() interface is true if the login is successful. The return value of the WGGetLoginRecord() interface is a flag that indicates whether the current token is valid or not.

6. Example Code

Here is an example code snippet that demonstrates how to use the WGLogin() interface:

WGPlatform.WGLogout();

7. Special Notes

No special notes are required for this guide.

Game Automatic Login Logic

The game automatic login logic involves calling the WGLogin() interface and waiting for the OnLoginNotify() callback. The process is as follows:

(./res/login_auto_login.png)

Game Token Acquisition Logic

When a game requires a login token, the WGGetLoginRecord() interface is called to retrieve the current login status. If the flag value is 5001, it indicates that the current token is valid, and the MSDK will automatically refresh the token.

The process is as follows:

(./res/login_get_login_record.png)

MSDK Internal Token Verification Logic

The MSDK internal token verification logic involves calling the WGGetLoginRecord() interface to retrieve the current login status and then verifying whether the token is valid or not. The process is as follows:

(./res/login_auto_refresh_token.png)

Frequently Asked Questions

Q: Do I need to use token validation when converting between foreground and background modes?
A: No, you do not need to use token validation when converting between foreground and background modes. The MSDK will automatically verify the token for you.

Q: What about Android WeChat login? Do I need to go through the same process?
A: No, you do not need to go through the same process for Android WeChat login. You can use the WXEntryActivity.java file to handle the login and token acquisition process.

###In this guide, we have discussed the MSDK login token management process for Android games. The MSDK provides a set of APIs and tools to help game developers integrate social features into their games. By following this guide, you can ensure that your game is properly integrated with the MSDK and that the login and token acquisition processes are handled correctly.

Leave a comment