Skip to main content

iOS

caution

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.

  1. VNG GameID
  2. appsFlyerDevKey (if you have applied for AppsFlyer from VNG)
  1. Create an account for Player Network Console.
  2. Create a new project for your game, or join an existing one.
  3. Download the SDK.
  4. Integrate the SDK.
  5. Add VNG as an authentication method for your project on Player Network Console.

Step 1: Configure the SDK

  1. Replace the GTModules.plist and GTSDK.plist files in the Player Network SDK with the ones provided by the VNG channel.

  2. Add VNG configs to the file Info.plist:

    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}"]
    }
    ]
    }
    }

Step 2: Add VNG login

  1. Add an observer to handle authentication callbacks.

    // 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";
    }
    }
  2. 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.

    INTLAPI.AutoLogin();
  3. Call the Login method to ask for user input if auto-login fails.

    INTLAPI.Login(INTLChannel.VNG, "", "");

    After calling the API, the following window will appear:

    Image: Login Interface

    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"
    }
    caution

    The user_id is the only identification of the current user, use it on the customer service interface.

  4. 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.

INTLAPI.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:

INTLAPI.Bind(INTLChannel.Facebook);

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:

string json="{\"user_id\":\"xxx\",\"login_type\":\"ZM\"}";;
INTLAPI.ExtendInvoke(INTLChannel.VNG, "showCustomerSupport",json);

The content in JSON includes the following fields, that users can fill in as needed:

NameFieldDescriptionRemarks
user_idstringLog in the user ID Required
login_typestringUser login type Required (zing corresponds: "zm")
role_namestringCharacter NameOptional
levelstringCharacter levelOptional
guildstringGroups of character belongingOptional
contentstringIs the character IDOptional
server_idstringServer IDOptional

The corresponding value of login_type is:

Login channelLogintype
GuestGU
FacebookFB
GoogleGG
ZingIDZM
LINELINE
AppleIDAP
EmailEM
ZaloZL
VNG IDCM

The following interface will appear after calling:

Image: Customer Service Service

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"
}