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 / Android / 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

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.

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 WGGetNearbyPersonInfo(), the interface of getting nearby persons, and WGCleanLocation(), the interface of clearing your own location information, will be returned to you through callback function OnLocationNofity(). The results of WGGetLocationInfo(), the interface of getting your own location information, will be returned to you through callback function OnLocationGotNotify ().

Callback of getting your own location information

1)Function description

Callback of getting your own location information

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

None

5)Demo code
@Override
public void OnLocationGotNotify(LocationRet locationRet) {
    Logger.d(locationRet.toString());
    String result = "flag: " + locationRet.flag + "\n" +
            "platform: " + locationRet.platform + "\n" +
            "longitude: " + locationRet.longitude + "\n" +
            "latitude: " + locationRet.latitude;
    //do some thing
}
6)Special description

None

7)Name 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 abstract void OnLocationNotify(RelationRet relationRet);
3)Parameter description
Return value name Parameter type Description
ret RelationRet the player's information set class
4)Return value

None

5)Demo code
void OnLocationNotify(RelationRet& relationRet) {
    switch (relationRet.flag) {
        case CallbackFlag.eFlag_Succ:
            // What stored in p is the nearby players' information 
            for(PersonInfo p:relationRet.persons){
                String gender = p.gender;
                String nickName = p.nickName;
                String openId = p.openId;
                String pictureLarge = p.pictureLarge;
                String pictureMiddle = p.pictureMiddle;
                String pictureSmall = p.pictureSmall;
                //...do some thing
            }

            break;
        default:
            break;
      }
}
6)Special description

None

7)Name 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 geographical location information: latitude and longitude.

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
public static bool WGGetLocationInfo();
3)Parameter description

None

4)Return value and callback description

No return value.The gotten result will be called back to the game through LocationRet carried by OnLocationGotNotify() callback function in register and implement callback function

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

None

7)Name interpretation

None

Get nearby persons' information

1 Summary

Get the current player's nearby players' information.

2 Registration callback

Please refer to Registration callback

3 Interface calling

1)Function description

Get the current player's nearby players' information. The result will be called back to the game through RelationRet carried by OnLocationNotify (RelationRet ret) callback function.

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

None

4)Return value

No return value. The gotten result, that is, nearby persons' information in Registration callback, will be called back to you through RelationRet carried by OnLocationNotify(RelationRet ret) callback function.

5)Demo code:
WGPlatform.WGGetNearbyPersonInfo();
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: 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 description

Call the location information clearing interface to clear the player's own location information. When other players try to get nearby people's information, they can't get the player's information. The result is returned via RelationRet carried by the callback function OnLocationNotify (RelationRet ret).

2)Interface declaration
public static boolean WGCleanLocation()
3)Parameter description

None

4)Return value

No return value.The gotten result will be called back to the game through RelationRet carried by OnLocationNotify(RelationRet ret) callback function in register and implement callback function

5)Demo code
WGPlatform.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 General description

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

class MyObserver : public WGPlatformObserver
{
public:
    ...    
    // Get IP information callback
    void OnLocationGetIPInfoNotify(GetIPInfoRet& ipInfoRet);
    ...
};

3 Interface invocation

WGPlatform::GetInstance()->WGGetIPInfo();