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

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

Since MSDK3.3.8, LBS-related functions have been changed into a separate library called MSDKLbs.framework, but the external interface remains unchanged. Various games can access the MSDK when needed.

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
3) In order to be compatible with iOS8 system, it is needed to add NSLocationWhenInUseUsageDescription(string) field in info.plist, as shown in the figure below

2 Refer to demos

For callback setting, please refer to OnLocationNotify and OnLocationGotWithLocationRet method shown in MSDKDemo/MyObserver.mm .

For details about how to call the interface, refer to onClickGetNearbyPeople, onClickClearMyLocation and onClickMyLocationInfo methods in MSDKDemo/LoginSucceedVC.mm file.

Get the player's location information

Registration callback

1)Function description

WGGetLocationInfo, an interface used to get the player’s location information, can return the got geographical location information (latitude and longitude) to the game through the callback OnLocationGotNotify.

2)Interface declaration
void OnLocationGotNotify(LocationRet& locationRet)
3)Parameter description
return value name type description
locationRet LocationRet class location information struct
4)Return value

None

5)Demo code
void MyObserver::OnLocationGotNotify(LocationRet& locationRet)
{
    NSString *flag = [NSString stringWithFormat:@"%d",locationRet.flag];
    NSString *desc = [NSString stringWithCString:(const char*)locationRet.desc.c_str() encoding:NSUTF8StringEncoding];
    NSString *latitudeStr = [NSString stringWithFormat:@"%f",locationRet.latitude];
    NSString *longitudeStr = [NSString stringWithFormat:@"%f",locationRet.longitude];
    NSMutableDictionary *personInfoDict = [NSMutableDictionary new];
    [personInfoDict setObject:flag forKey:@"flag"];
    [personInfoDict setObject:desc forKey:@"desc"];
    [personInfoDict setObject:latitudeStr forKey:@"latitude"];
    [personInfoDict setObject:longitudeStr forKey:@"longitude"];
}
6)Special description

None

7)Term interpretation

None

Call interfaces

1)Function description

Get the player’s geographical location information: latitude and longitude. The call result will be called back to OnLocationGotNotify.

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

None

4)Return value

If the call is normal, “Yes” will be returned; if there is no login, appid is null and openid is null, “NO” will be returned.

5)Demo code
WGPlatform::GetInstance()->WGGetLocationInfo();
6)Special description

None

7)Term interpretation

None

Get nearby persons' information

Registration callback

1)Function description

Get the current player's nearby players’ information. The result will be called back to the game through OnLocationNotify .

2)Interface declaration
void OnLocationNotify(RelationRet &relationRet)
3)Parameter description
return value name type description
relationRet RelationRet class user information struct
4)Return value

None

5)Demo code
void MyObserver::OnLocationNotify(RelationRet &relationRet) {
    NSLog(@"location callback");
    NSLog(@"count == %lu",relationRet.persons.size());
    NSMutableArray *personInfoArr = [NSMutableArray new];
    for (int i = 0; i < relationRet.persons.size(); i++)
    {
        PersonInfo logInfo = relationRet.persons[i];
        NSMutableDictionary *personInfoDict = [NSMutableDictionary new];
        NSString *nickName = [NSString stringWithCString:(const char*)logInfo.nickName.c_str() encoding:NSUTF8StringEncoding];
        NSString *openID = [NSString stringWithCString:(const char*)logInfo.openId.c_str() encoding:NSUTF8StringEncoding];
        NSString *gender = [NSString stringWithCString:(const char*)logInfo.gender.c_str() encoding:NSUTF8StringEncoding];
        NSString *pictureSmall = [NSString stringWithCString:(const char*)logInfo.pictureSmall.c_str() encoding:NSUTF8StringEncoding];
        NSString *pictureMiddle = [NSString stringWithCString:(const char*)logInfo.pictureMiddle.c_str() encoding:NSUTF8StringEncoding];
        NSString *pictureLarge = [NSString stringWithCString:(const char*)logInfo.pictureLarge.c_str() encoding:NSUTF8StringEncoding];
        NSString *province = [NSString stringWithCString:(const char*)logInfo.provice.c_str() encoding:NSUTF8StringEncoding];
        NSString *city = [NSString stringWithCString:(const char*)logInfo.city.c_str() encoding:NSUTF8StringEncoding];
        NSString *gpsCity = [NSString stringWithCString:(const char*)logInfo.gpsCity.c_str() encoding:NSUTF8StringEncoding];
        NSString *country = [NSString stringWithCString:(const char*)logInfo.country.c_str() encoding:NSUTF8StringEncoding];
    }
}
6)Special description

None

7)Term interpretation

None

Call interfaces

1)Function description

Get the current player's nearby game players’ information.

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

None

4)Return value

None

5)Demo code
WGPlatform::GetInstance()->WGGetNearbyPersonInfo();
6)Special description

None

7)Term interpretation

None

Clear the location information

Registration callback

Like the interfaces used to get nearby persons’ information, the callback method of the location information clearing interface, WGCleanLocation, can call the result back to OnLocationNotify. For details, please refer to Callback setting of getting nearby persons’ information.

Call interfaces

1)Function description

A player’s own location information can be cleared by calling the location information clearing interface. If other players get nearby persons’ info, they can’t get the player's information.

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

None

4)Return value

If the call is normal, “Yes” will be returned; if there is no login, appid is null and openid is null, “NO” will be returned.

5)Demo code
WGPlatform::GetInstance()->WGCleanLocation();
6)Special description

None

7)Term interpretation

None

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();