iOS
This article guides you through setting up Google as an identity provider, enabling your iOS game to access Player Network authentication services.
Prerequisites
1. Set up the Google app on the Google Play Console
For IEGG projects, contact [miaruan (Ruan Mingjun)] for Google app registration and configuration.
1. Create a Google app
Register an account on Google Play Console following the prompts.
Google charges a fee of 25USD for the service. Please prepare a credit card in advance.
Go to the Google Play Console.
On the All apps page, click Create app to create a game app.
Enter the app information.
2. Create a Play Games Services game project
Set up Play Games Services to manage game metadata and automate game production and distribution tasks.
Go to Google Play Console.
On the left navigation bar, select Grow > Play Games Services > Setup and management > Configuration.
Under Does your game already use Google APIs, select the correct answer and your Play Games Services game project is created.
In the Properties section, click Edit Properties.
Enter basic game information and click Save changes.
3. Add a credential to link the OAuth 2.0 client ID to your game
Go to Google Cloud Platform.
On the left navigation bar, click OAuth consent screen.
Follow the instructions to setup the OAuth consent screen.
On the left navigation bar, click Credentials.
On the Credentials page, select CREATE CREDENTIALS > OAuth Client ID to create an OAuth client ID.
Add both Android and Web OAuth clients.
- The Android client is used for client login.
- The Web client is used by Player Network SDK to obtain offline authorization, and the client ID is the Server Client ID.
Android
In the Authentication type list, click Android.
Enter the Package Name and SHA-1 Certificate Fingerprint.
Confirm the Package Name and SHA-1 Certificate Fingerprint with the development team. The OAuth client for Android requires users to configure the SHA-1 certificate fingerprint and package name in the KeyStore. Make sure the two values are correct. Otherwise, the login process will throw an exception.Click SAVE to complete the configuration.
Go to the details page of the Android app.
Find the Client ID and Client Secret, and enter them into the game configuration of the Player Network Console.
Web
In the Authentication type list, click Web.
Enter the required information.
In the Authorized redirect URLs section of the web application details page, addhttps://test-common-web.intlgame.com/jssdk/googlelogincallback.html
andhttps://common-web.intlgame.com/jssdk/googlelogincallback.html
.Click SAVE to complete the configuration.
Go to the details page of the Web app.
Find the Client ID and Client Secret, and enter them into the game configuration of the Player Network Console.
Add login test users.
4. Configure for API access
Go to Google Cloud Platform.
On the left navigation bar, select Settings > Developer account > API access.
One the API access page, accept the Terms of Service.
Click Link on the right of the corresponding project to link Google Play Console to the API project.
5. Add testers for your game
Go to Google Play Console.
On the left navigation bar, select Grow > Play Games Services > Setup and management > Testers.
In the Testers tab, click Add testers to add testers for your game.
Before the game app is released, only testers can log in. Please make sure that the app is in the testing status.
6. Configure Achievements and Leaderboards
Find the Achievements and Leaderboards functions in the Games Services menu and configure them as needed.
7. Get Google API ID
Access the Information Center from the Google Cloud Platform dashboard. The Google API ID is the Project No. on this page.
8. Get the Client ID and Client secret
Follow the steps in Add a credential to link the OAuth 2.0 client ID to your game to get the application information.
- 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 Google as an authentication method for your project on Player Network Console.
Step 1: Configure the SDK for Google login
Open the INTLConfig.ini file.
INTLConfig.ini[INTL environment]
# WARNING: You should change this URL to the production environment when you release your game.
INTL_URL = https://test.intlgame.com
GAME_ID = {INTL_GAME_ID}
SDK_KEY = {INTL_SDK_KEY}
[INTL Log]
LOG_LEVEL = 1
LOG_CONSOLE_OUTPUT_ENABLE = 1
LOG_FILE_OUTPUT_ENABLE = 1
LOG_ENCRYPT_ENABLE = 0
LOG_COMPRESS_ENABLE = 0
[Google Channel Configuration]
GOOGLE_CLIENT_KEY_IOS = {INTL_GOOGLE_CLIENT_KEY}- Set the SDK backend environment to
INTL_URL = https://test.intlgame.com
. - Replace
{INTL_GAME_ID}
and{INTL_SDK_KEY}
with theGAME_ID
andSDK_KEY
assigned by Player Network Console. - Set
LOG_LEVEL = 1
,LOG_CONSOLE_OUTPUT_ENABLE = 1
,LOG_FILE_OUTPUT_ENABLE = 1
,LOG_ENCRYPT_ENABLE = 0
, andLOG_COMPRESS_ENABLE = 0
to output console logs and log files without encrypting or compressing the output. - Replace
{INTL_GOOGLE_CLIENT_KEY}
with the registered Google Client ID for iOS.
- Set the SDK backend environment to
Add Google to the
Info.plist
file.- Unity
- Unreal Engine
{
"group": "INTL",
"libs": ["libz.tbd", "libsqlite3.0.tbd"],
"frameworks": ["SafariServices.framework", "LocalAuthentication.framework", "AuthenticationServices.framework"],
"Info.plist":{"CFBundleURLTypes": [{"CFBundleURLName": "Google", "CFBundleTypeRole": "Editor", "CFBundleURLSchemes": ["com.googleusercontent.apps.{INTL_GOOGLE_APP_ID}"]}]}
}Check the predefined values in
INTLGoogleKit.projmods
and replace{INTL_GOOGLE_APP_ID}
with the Google App ID before exporting the Xcode project from Unity.Add the SDK-related configuration to the PLIST file.
- Player Network SDK 1.18 or later
- Before Player Network SDK 1.18
Open and modify the file that corresponds to your SDK version:
- For V1.24 or later:
INTLSDK/Source/INTLGoogle/Libs/iOS/INTLGoogle_UPL.xml
- For V1.18 to V1.23:
INTLSDK/Source/INTLConfig/Configs/iOS/Plist/INTLGoogle.plist
<key>CFBundleURLSchemes</key>
<array>
<string>{INTL_GOOGLE_REVERSED_CLIENT_ID}</string>
</array>Go to Unreal Engine > Settings > Project Settings > Platforms > iOS > Extra PList Data to add SDK to Plist.
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>Google</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>{INTL_GOOGLE_REVERSED_CLIENT_ID}</string>
</array>
</dict>
</array>Replace {INTL_GOOGLE_REVERSED_CLIENT_ID} with iOS URL scheme.
Various access data can be found from Google Cloud Console - Credentials:
Step 2: Add Google login
All Google operations require a connection to Google services.
Automatic Login (AuthLogin)
During automatic login, the device may be unable to connect to Google services. By default, Player Network SDK connects to Google services upon automatic login, which is recommended. (Game teams can disable the connection by configuring the GOOGLE_LOGOUT_NEED_CONNECT field as instructed in Google Channel Configuration
.)
Login
Before calling Google login, Player Network SDK will check if Google Mobile Services (GMS) is available. The login service can be called only when GMS is available. If GMS is unavailable, Player Network SDK will return the error code returned by Google to games through the ThirdCode
field of INTLAuthResult
.
Return code | Value | Error Description |
---|---|---|
SERVICE_MISSING | 1 | The GMS is unavailable on the device. |
SERVICE_VERSION_UPDATE_REQUIRED | 2 | The installed GMS version has expired. |
SERVICE_DISABLED | 3 | The GMS is disabled. |
SERVICE_INVALID | 9 | The installed GMS version is incorrect. |
SERVICE_UPDATING | 18 | The GMS is being updated on the device. |
For more information, see Google Docs and Google FAQs
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.- 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.Google);
UINTLSDKAPI::Login(EINTLLoginChannel::kChannelGoogle);
Sync client authentication state with the game's backend and wait for the final authentication result.
[Optional] Set up email permissions
Set up permissions to obtain the email address of players during Google login, returned as email
in the ChannelInfo
of AuthResult
.
- Email masking can be performed on the returned
email
according to compliance requirements, reach out to the Player Network representative to enable this feature. - The hashed
base64(sha256(email))
can be reported to the backend logs, reach out to the Player Network representative to enable this feature. - Can be used to verify if
email
is present in a player's profile or third-party channel information, reach out to the Player Network representative to enable this feature. - Can be used to enable Private Set Membership (PSM) for Firebase on iOS, see Firebase iOS configurations for more details.
Enable email return on Player Network Console by setting return_email to YES, see Configure Third-party Channels for detailed procedures.
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.
Step 4: Release your game
Before preparing for a production release, create a testing release with Android App Bundle.
The advantage of releasing a Beta version is that users can download it from Google play, but have no permission to add comments. A specific channel is set for users to submit feedback.
Create a production release
Go to Google Play Console.
On the left navigation bar, select Release > Production.
Follow the instructions to create the production release.
Change the publishing status
If users do not release the app, authentication may fail.
Go to the OAuth consent screen page of Google Cloud Platform.
Change the Publishing status to PUBLISH APP.