LBS function
Unity3D
Outline
Access Guide
Get the player's location information
Get nearby persons' information
Clear the location information
Get IP information
Android
Outline
Access Guide
Get the player's location information
Get nearby persons' information
Clear the location information
Get IP information
IOS
Outline
Access Guide
Get the player's location information
Get nearby persons' information
Clear the location information
Get IP information
Others
Data Structure
System Tools
Crash report / Unity3D / Outline

Outline

LBS module can get the player's location information and get the nearby players' information, so that the player can interact with nearby players.


Description of what marked in the red frame in the diagram

Through LBS functions, you can get the nearby player's nickname, gender, distance and other information.

Access Guide

LBS function plug-in, business can be combined on demand.

  • Android 3.3.15a version starts to add MSDKLbs.jar, but the external interface remains unchanged. If LBS capability is not needed, just delete the MSDKLibrary/libs/MSDKLbs.jar file.
  • Starting from version 3.3.8, LBS-related functions have been changed to a separate library MSDKLbs.framework, the external interface remains unchanged, and various services can be accessed on demand.

1 Preconditions

1) You have completed initialization according to the initialization module's description initialization
2) Before calling LBS interfaces, you need to first login QQ/WeChat

2 Registration callback

Outline

The results of the nearby persons getting interface WGGetNearbyPersonInfo() and the location information clearing interface WGCleanLocation() can be returned to the game via the callback NearbyEvent. The result of the location information getting interface WGGetLocationInfo() can be returned to the game via the callback LocateEvent.

Callback of getting your own location information

1)Function description

Callback of getting your own location information

2)Interface declaration
public delegate void LocateDelegate(LocationRet ret);
3)Parameter description
Return value name Parameter type Description
ret LocationRet the player's location information class
4)Return value

None

5)Demo code
MsdkEvent.Instance.LocateEvent += (LocationRet locationret) => {
    Debug.Log(locationret.ToString());
    message = locationret.ToString();
    if (locationret.flag == eFlag.eFlag_Succ) {
        // Get the location information successfully
    } else {
        // Get the location information unsuccessfully
    }
}
6)Special description

None

7)Term interpretation

None

Callback of getting nearby persons and clearing your own location information

1)Function description

Callback of getting nearby persons and clearing your own location information

2)Interface declaration
public delegate void NearbyDelegate(RelationRet ret);  
3)Parameter description
Return value name Parameter type Description
ret RelationRet the player's information set class
4)Return value

None

5)Demo code
MsdkEvent.Instance.NearbyEvent += (RelationRet relationRet) => {
    Debug.Log(relationRet.ToString());
    if (relationRet.flag == eFlag.eFlag_Succ) {
        // Query nearby persons successfully
        //Game TODO Get nearly persons' information
    } else {
        // Fail to query nearby persons
        //Game TODO Handled according to different return values
    }
}
6)Special description

None

7)Term interpretation

None

3 Call LBS interfaces to get information

At this time, you can call MSDK interfaces to get geographical position information. For details, please refer to Get the player's location information, Get nearby persons, Clear location information.

Congratulations on your completion of access to LBS functions!

Get the player's location information

1 Summary

Get the player's location information

2 Registration callback

Please refer to Registration callback

3 Interface calling

1)Function description

Get the player's geographical location information: latitude and longitude.

2)Interface declaration
bool WGGetLocationInfo();
3)Parameter description

None

4)Return value

No return value. The gotten result will be returned through LocationRet carried by LocateEvent event in Register and realize callback function

5)Demo code
WGPlatform.Instance.WGGetLocationInfo();
6)Special description

None

7)Term interpretation

None

Get nearby persons' information

1 Summary

Get nearby persons' information

2 Registration callback

Please refer to Registration callback

3 Interface calling

1)Function description

Get the current player's nearby players' information, and the result will be returned through RelationRet carried by NearbyEvent.

2)Interface declaration
void WGGetNearbyPersonInfo();
3)Parameter description

None

4)Return value

No return value. The gotten result will be returned to you through RelationRet carried by NearbyEvent in Register callback

5)Demo code:
void WGGetNearbyPersonInfo ();
6)Special description

None

7)Term interpretation

RelationRet.flag value indicates the return state; its possible values (eFlag enumeration) are as follows:

eFlag_LbsNeedOpenLocationService: need to guide the user to open the location-based service(LBS)
eFlag_LbsLocateFail: Positioning fails. You can retry
eFlag_Succ: Get nearby persons' info successfully
eFlag_Error:  Positioning succeeds, but requesting nearby persons' info fails. You can retry

RelationRet.persons is a Vector, which stores the nearby players' information. For details, please refer to constant query

Clear the location information

1 Summary

The location information clearing interface can be called to clear a player's own location information. When other players try to get nearby people's information, they can't get the player's information.

2 Registration callback

Please refer to Registration callback

3 Interface calling

1) Function explanation

Call the location information clearing interface to clear the player's own location information. When other players get nearby people's location information, they can't get the player's location information. The result is returned by RelationRet ret, which is carried in NeighborEvent.

2)Interface declaration
bool WGCleanLocation();
3)Parameter description

None

4)Return value

true or false, which indicates whether or not the request for clearing location is sent to the server. The gotten result will be returned through RelationRet carried in NearbyEvent event in Register and realize callback function

5)Demo code
WGPlatform.Instance.WGCleanLocation();
6)Special description

None

7)Name interpretation

RelationRet.flag value indicates the return state; its possible values (eFlag enumeration) are as follows:
eFlag_LbsNeedOpenLocationService: need to guide the user to open the location-based service(LBS)
eFlag_LbsLocateFail: Positioning fails. You can retry
eFlag_Succ: Cleared successfully

Get IP information

1 概要说明

MSDK provides a location information service based on the user's exit IP. Currently, it can provide national, provincial and municipal information to meet business needs. Note: If the user uses VPN, network proxy, accelerator (partial) and other scenes, MSDK can obtain the IP location information of the corresponding server. For details, please refer to MSDK IP Access Location Information Service Description. 3.3.271 version starts adding this interface

2 Registration callback

MsdkEvent.Instance.OnLocationGetIPInfoEvent += (GetIPInfoRet relationRet) => {
    //Your code here
}

3 Interface invocation

WGPlatform.Instance.WGGetIPInfo();