Skip to main content

Android

This article guides you through setting up Supercell as an identity provider, enabling your Android game to access Player Network authentication services.

Prerequisites

1. Get app information

Get required app information from the Supercell team.

  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 Supercell as an authentication method for your project on Player Network Console.

Step 1: Configure the SDK

caution

As Supercell SDK is only compatible with minSdkVersion >= 21, problems may occur while running on devices with Android 5.0 or lower versions. It is required to set minSdkVersion >= 21 for your game.

For more information, see Integrate into Android.

  1. In the AndroidManifest file, add required permissions. Supercell needs network access to obtain network information status and write to SD card permissions.

    caution

    WRITE_EXTERNAL_STORAGE is a sensitive permission.

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  2. Open the project's INTLConfig.ini:

    [Supercell]
    SUPERCELL_GAME_ID = {INTL_SUPERCELL_GAME_ID}
    SUPERCELL_GAME_ENVIRONMENT = {INTL_SUPERCELL_GAME_ENVIRONMENT}
    SUPERCELL_IS_PRODUCTION = {IS_USING_PRODUCTION}
    • Replace {INTL_SUPERCELL_GAME_ID} with the GAME_ID assigned by Player Network Console.
    • Replace {INTL_SUPERCELL_GAME_ENVIRONMENT} with the environment you are using, such as dev or prod.
    • Set {IS_USING_PRODUCTION}, 1 indicates a production environment, and 0 indicates any other environment.

Step 2: Add Supercell 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.

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

    INTLAPI.Login(INTLChannel.Supercell); 
  4. Sync client authentication state with the game's backend and wait for the final authentication result.

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.