Unreal Engine
Learn how to use Stash's Unreal SDK for Unreal Engine 5
The Unreal SDK is in beta. Please contact us to get access.
This guide explains how to integrate Apple and Google account linking into your Unreal Engine 5 project using Stash's SDK. This integration allows players to sign in and link their Apple and Google accounts for authentication within your Unreal Engine application.
Prerequisites
Before you begin, make sure you:
- Install Unreal Engine 5.
- Have an Apple Developer Account for setting up sign in with Apple.
- Have access to the Google Developer Console for configuring Google Sign-In.
- Have basic knowledge of Unreal Engine 5 and C++/Blueprint scripting.
1. Set up your Unreal Project
Install the Stash Unreal SDK. Ensure the SDK is linked correctly by testing it with an API call, or verifying the SDK initialization. Then, navigate to Edit > Project Settings in Unreal Engine and configure the following project settings.
- Navigate to Platforms > iOS and Platforms > Android to configure the necessary settings for Apple and Google Sign-In respectively.
- Ensure that your project has the correct Bundle Identifier (iOS) and Package Name (Android).
2. Set up sign in with Apple
First, create an App ID in your Apple Developer account:
- Log in to your Apple Developer account.
- Navigate to Certificates, Identifiers & Profiles.
- Create an App ID and enable the Sign In with Apple capability.
Then, create a Service ID and configure the redirect URL:
- Create a Service ID under Identifiers.
- Enable Sign In with Apple for this Service ID.
- Add your app’s redirect URL under the Service ID configuration.
Generate and download an Apple Authentication Key with Sign In with Apple enabled, and then configure your Unreal project:
- In Project Settings, under Platforms > iOS, enable Sign In with Apple.
- Ensure the correct Entitlements file is linked to your project.
You can now use Stash SDK methods to initiate and handle the sign in process.
// Include the Stash SDK header
#include "StashSDK.h"
void MyGameInstance::SignInWithApple()
{
UStashSDK::SignInWithApple(FOnStashSignInCompleted::CreateUObject(this, &MyGameInstance::OnAppleSignInCompleted));
}
void MyGameInstance::OnAppleSignInCompleted(bool bSuccess, const FString& ErrorMessage)
{
if (bSuccess)
{
// Handle successful sign-in
}
else
{
// Handle sign-in failure
}
}
Ensure the sign in with Apple button is appropriately styled and placed within your UI.
3. Set Up Google Sign-In
Start by creating a project in your Google Developer Console. Then, configure the OAuth Consent Screen under APIs & Services with the necessary details. Make sure to enable the Google Sign-In API for the project, and then create OAuth client IDs:
- Create an OAuth 2.0 Client ID for both iOS and Android.
- Add the necessary redirect URIs.
Within your Unreal project, ensure the required permissions for Google Sign-In are added to Project Settings under Platforms > Android.
You can now use Stash SDK methods to initiate and handle the sign in process.
// Include the Stash SDK header
#include "StashSDK.h"
void MyGameInstance::SignInWithGoogle()
{
UStashSDK::SignInWithGoogle(FOnStashSignInCompleted::CreateUObject(this, &MyGameInstance::OnGoogleSignInCompleted));
}
void MyGameInstance::OnGoogleSignInCompleted(bool bSuccess, const FString& ErrorMessage)
{
if (bSuccess)
{
// Handle successful sign-in
}
else
{
// Handle sign-in failure
}
}
Ensure the Google Sign-In button is appropriately styled and placed within your UI.
4. Handle account linking
After players are authenticated, use the Stash SDK to link their accounts with their game profile.
void MyGameInstance::LinkAccount(const FString& Provider)
{
UStashSDK::LinkAccount(Provider, FOnStashAccountLinkCompleted::CreateUObject(this, &MyGameInstance::OnAccountLinkCompleted));
}
void MyGameInstance::OnAccountLinkCompleted(bool bSuccess, const FString& ErrorMessage)
{
if (bSuccess)
{
// Handle successful account linking
}
else
{
// Handle account linking failure
}
}
Multiple linked accounts
Some players might want to link both their Apple and Google accounts. Make sure your game and UI can handle these scenarios.
5. Test your integration
Test the integration on both iOS and Android platforms, and make sure the account linking flows work as expected. You might need to use the logging and debugging tools provided by the Unreal Engine and the Stash SDK to troubleshoot any issues.
Updated about 2 months ago