iOS
This article guides you through setting up Twitter as an identity provider, enabling your iOS game to access Player Network authentication services.
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 Twitter 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.
As Player Network SDK only supports Twitter web login, the INTLTwitter
plugin depends on the INTLWKWebViewJavascriptBridge
of the WebView component to retrieve login information returned by the Twitter login webpage.
Prerequisites
1. Set up the Twitter app on the Twitter Developer Platform
1. Create a Twitter app
It is recommended to register an account with a Tencent email address, which can increase the success rate of later applications.
Register a team developer account or individual developer account on the Twitter developer website according to the prompts. With a developer account, you can create your app in the Developer Portal.
Create a new project.
Select a use case. Click Next.
Enter the project description. Click Next.
Select the application environment. Click Save.
Enter the app name. Click Save.
Obtain the API key and API secret key after creating an app. Store this information. Click App Settings.
cautionThis is the last time you will see this screen. Do store this information.
Click Set up.
Enable OAuth2.0 and OAuth1.0a. Select Web App for Type Of App.
Select Read And Write for App Permissions.
For callback URLs, enter the testing environment and production environment URLs. You will enter the game's official website. Click Save.
If the game is already online, the existing callback URLs cannot be deleted, only added.
Player Network SDK V1.15 and earlier
https://image.intlgame.com/v2/test/jssdk/twitterlogincallback.html
https://image.intlgame.com/v2/release/jssdk/twitterlogincallback.html
Player Network SDK V1.16 and later
https://test-common-web.intlgame.com/jssdk/twitterlogincallback.html
https://common-web.intlgame.com/jssdk/twitterlogincallback.html
To log in with the Twitter SDK in INTLConfig.ini when TWITTER_CONSUMER_USE_SDK
is 1, add the following callback URL:
twittersdk://
twitterkit-{API Key}://
{API Key}
needs to be replaced with the API Key of the game, excluding curly brackets {}.
2. Retrieve app information
You need the Twitter app ID and secret to add Twitter as a login channel on Player Network.
- 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 Twitter as an authentication method for your project on Player Network Console.
Step 1: Configure the SDK for Twitter 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
[Twitter]
TWITTER_CONSUMER_KEY = {INTL_TWITTER_CONSUMER_KEY}
TWITTER_CONSUMER_SECRET = {INTL_TWITTER_CONSUMER_SECRET}- 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_TWITTER_CONSUMER_KEY}
and{INTL_TWITTER_CONSUMER_SECRET}
with the Twitter API key and API Key Secret.
- Set the SDK backend environment to
Add Twitter to the
Info.plist
file.- Unity
- Unreal Engine
Check the predefined values in
INTLTwitterKit.projmods
and replace{INTL_TWITTER_CONSUMER_KEY}
with the Twitter API Key before exporting the Xcode project from Unity.{
"group": "INTL",
"Info.plist":{
"LSApplicationQueriesSchemes":
[
"twitter",
"twitterauth",
],
"CFBundleURLTypes" :
[
{
"CFBundleTypeRole":"Editor",
"CFBundleURLSchemes":["twitterkit-{INTL_TWITTER_CONSUMER_KEY}"]
}
]
}
}- 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/INTLTwitter/Libs/iOS/INTLTwitter_UPL.xml
- For V1.18 to V1.23:
INTLSDK/Source/INTLConfig/Configs/iOS/Plist/INTLTwitter.plist
<key>CFBundleURLSchemes</key>
<array>
<string>twitterkit-{INTL_TWITTER_CONSUMER_KEY}</string>
</array>Go to Unreal Engine > Settings > Project Settings > Platforms > iOS > Extra Plist Data to modify the configuration and add SDK in the PLIST file.
<key>CFBundleURLTypes</key>
...
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>twitterkit-{INTL_TWITTER_CONSUMER_KEY}</string>
</array>
</dict>
</array>
...
<key>LSApplicationQueriesSchemes</key>
<array>
<string>twitter</string>
<string>twitterauth</string>
</array>Replace
{INTL_TWITTER_CONSUMER_KEY}
with the Twitter API Key.If there is a need to call Twitter friends, in INTLTwitter’s iOS plugin, find the BuildPhrases configuration of the project in the Xcode project, and add or modify the following configuration:
MapKit.framework
Accounts.framework
CoreData.framework
Step 2: Add Twitter login
After logging in, select Twitter Channel to link it. If a user used a linked Twitter account, a server error will be displayed. Calling the Bind
method again will require the user to log in to Twitter again.
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.Twitter);
UINTLSDKAPI::Login(EINTLLoginChannel::kChannelTwitter);
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 Twitter 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.
Under User authentication settings in the Twitter Developer Platform, enable Request email from users.
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.