iOS
From Spring 2024, developers will have to clearly describe data use in the privacy manifest, showing how required reason APIs will be utilized in apps that are updated or uploaded to Apple App Store Connect. For more information, see Upcoming third-party SDK requirements.
As VNG has yet to publish their privacy manifest, such content is not available in the Player Network SDK privacy manifest, see iOS 17 Privacy Manifest for more information.
This article guides you through setting up VNG as an identity provider, enabling your iOS game to access Player Network authentication services.
Prerequisites
1. Set up the VNG app
Contact VNG to apply the following app configuration parameters.
- VNG GameID
- appsFlyerDevKey (if you have applied for AppsFlyer from VNG)
- Create an account for Player Network Console.
- Create a new project for your game, or join an existing one.
- Download the SDK.
- Integrate the SDK.
- Add VNG as an authentication method for your project on Player Network Console.
Step 1: Configure the SDK
Replace the
GTModules.plist
andGTSDK.plist
files in the Player Network SDK with the ones provided by the VNG channel.Add VNG configs to the file
Info.plist
:- Unity
- Unreal Engine
Before exporting the Xcode project from Unity, check the pre-defined values in
INTLVNGKit.projmods
, replace{INTL_VNG_GG_APP_ID}
with the VNG App ID, and replace{INTL_VNG_GG_CLIENT_TOKEN}
with the VNG Client Token.{
"group": "INTL",
"Info.plist":{
"NSUserTrackingUsageDescription" : "VNG need tracking permission",
"LSApplicationQueriesSchemes":
[
"ggvng-api"
],
"GGVNGClientID":"{INTL_VNG_GG_APP_ID}",
"GGVNGClientToken":"{INTL_VNG_GG_CLIENT_TOKEN}",
"CFBundleURLTypes" :
[
{
"CFBundleTypeRole":"Editor",
"CFBundleURLName":"VNG",
"CFBundleURLSchemes":["gg-{INTL_VNG_GG_APP_ID}"]
}
]
}
}Modify
INTLSDK/Source/INTLConfig/Configs/iOS/Plist/INTLVNG.plist
, replace{INTL_VNG_GG_APP_ID}
with the VNG App ID, and replace{INTL_VNG_GG_CLIENT_TOKEN}
with the VNG Client Token.<plist version="1.0">
<dict>
<key>NSUserTrackingUsageDescription</key>
<string>VNG need tracking permission</string>
<key>GGVNGClientID</key>
<string>{INTL_VNG_GG_APP_ID}</string>
<key>GGVNGClientToken</key>
<string>{INTL_VNG_GG_CLIENT_TOKEN}</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>ggvng-api</string>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>VNG</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>gg-{INTL_VNG_GG_APP_ID}</string>
</array>
</dict>
</array>
</dict>
</plist>
Step 2: Add VNG login
Add an observer to handle authentication callbacks.
- Unity
- Unreal Engine
// Add callbacks
public void AddAuthObserver()
{
INTLAPI.AddAuthResultObserver(OnAuthResultEvent);
}
// Remove callbacks
public void RemoveAuthObserver()
{
INTLAPI.RemoveAuthResultObserver(OnAuthResultEvent);
}
// Process the INTLAuthResult callback
public void OnAuthResultEvent(INTLAuthResult ret)
{
Debug.Log($"MethodID: {ret.MethodId}");
string methodTag = "";
if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_LOGIN)
{
methodTag = "Login";
}
else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_BIND)
{
methodTag = "Bind";
}
else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_AUTOLOGIN)
{
methodTag = "AutoLogin";
}
else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_QUERY_USER_INFO)
{
methodTag = "QueryUserInfo";
}
else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_GET_AUTH_RESULT)
{
methodTag = "GetAuthResult";
}
}C++ Event Handling (above v1.15)
//configure callback
FINTLAuthEvent authEvent;
authEvent.AddUObject(this, &OnAuthResult_Implementation);
UINTLSDKAPI::SetAuthResultObserver(authEvent);
// Remove callbacks
UINTLSDKAPI::GetAuthResultObserver().Clear();void OnAuthResult_Implementation(FINTLAuthResult ret)
{
UE_LOG(LogTemp, Warning, TEXT("MethodID: %d"), ret.MethodId);
}Unreal Event Handling
void OnAuthResult_Implementation(FINTLAuthResult ret)
{
UE_LOG(LogTemp, Warning, TEXT("MethodID: %d"), ret.MethodId);
}Call the
AutoLogin
method.When a user has logged in before, the game backend can achieve automatic login by calling the auto-login interface. If the token is still effective within the validity period, login will be successful. If the token fails, an error prompt will appear, and the game needs to call the manual login interface to log in again.
- Unity
- Unreal Engine
INTLAPI.AutoLogin();
UINTLSDKAPI::AutoLogin();
Call the
Login
method to ask for user input if auto-login fails.- Unity
- Unreal Engine
INTLAPI.Login(INTLChannel.VNG, "", "");
UINTLSDKAPI::Login(EINTLLoginChannel::kChannelVNG);
After calling the API, the following window will appear:
The parameter returned after logging in is:
{
"extraJson":"
{
}",
"methodID":102,
"retCode":0,
"retMsg":"Success",
"ret":0,
"msg":"success",
"bind_list":"",
"birthday":"",
"channel":"VNG",
"channel_info":"
{
\"email\":\"null\",
\"expire_ts\":1660373805,
\"session_id\":\"MTSVN_23195b047d99a2b164296ab85cb956fa76e631657781803922\",
\"social_id\":\"646605735\",
\"update_in\":1657781803520,
\"user_id\":\"2213855217680687104\",
\"user_name\":\"mtschecking02\"
}",
"channelid":38,
"confirm_code":"",
"confirm_code_expireTime":0,
"del_account_status":-10,
"first_login":0,
"gender":0,
"legal_doc":"",
"openid":"824624458301451",
"pf":"unknown_uk-00000000-android-00000000-uk-MTSVN-824624458301451",
"pf_key":"4c5a49c1407cfe7ab09fba44e343810e",
"picture_url":"",
"need_name_auth":false,
"token":"bd13b7147297a5c58c27f414ea21ae00f67f2208",
"token_expire_time":1660373805,
"user_name":"mtschecking02"
}cautionThe user_id is the only identification of the current user, use it on the customer service interface.
Sync client authentication state with the game's backend and wait for the final authentication result.
Logout
Users can log out of the current login channel. The game backend need to call the interface Logout
and pass the relevant parameters.
- Unity
- Unreal Engine
INTLAPI.Logout();
UINTLSDKAPI::Logout();
Step 3: Test the login function
Search for the keyword "AuthResult" in the Player Network SDK logs to verify if the correct channel name and OpenID are returned. If they are, it indicates a successful configuration and the login function has been added successfully.
Other Functions
Link
Users can link VNG and channels that have been logged in, such as operations such as synchronous data. Users can call the Bind
interface and pass the relevant parameters.
Taking Facebook as an example:
- Unity
- Unreal Engine
INTLAPI.Bind(INTLChannel.Facebook);
UINTLSDKAPI::Bind(EINTLLoginChannel::kChannelFacebook);
For more information, see the Bind
API for Unity SDK or Unreal Engine SDK.
VNG Customer Service
VNG provides customer service, and supports it through extend in Player Network SDK. The callback is:
- Unity
- Unreal Engine
string json="{\"user_id\":\"xxx\",\"login_type\":\"ZM\"}";;
INTLAPI.ExtendInvoke(INTLChannel.VNG, "showCustomerSupport",json);
FString json="{ \"user_id\":\"xxx\",\"login_type\":\"ZM\"}";;
UINTLSDKAPI::ExtendInvoke(EINTLLoginChannel::kChannelVNG, "showCustomerSupport",json);
The content in JSON includes the following fields, that users can fill in as needed:
Name | Field | Description | Remarks |
---|---|---|---|
user_id | string | Log in the user ID | Required |
login_type | string | User login type | Required (zing corresponds: "zm") |
role_name | string | Character Name | Optional |
level | string | Character level | Optional |
guild | string | Groups of character belonging | Optional |
content | string | Is the character ID | Optional |
server_id | string | Server ID | Optional |
The corresponding value of login_type is:
Login channel | Logintype |
---|---|
Guest | GU |
FB | |
GG | |
ZingID | ZM |
LINE | LINE |
AppleID | AP |
EM | |
Zalo | ZL |
VNG ID | CM |
The following interface will appear after calling:
The following parameter will be returned when the page is closed:
{
"extraJson":"
{
}",
"methodID":1301,
"retCode":0,
"retMsg":"Success",
"ret":0,
"msg":"",
"channel":"VNG",
"extend_method_name":"showCustomerSupport"
}