Skip to main content

iOS Signup and Authentication

Sign up and authenticate using Apple ID.

URL Confirmation

This API uses the service-account.playnanoo.com domain.

Apple Authentication Plugin Registration

Utilize Unreal Engine's Online Subsystem Apple or use a third-party plugin.

API Information

  • URL: https://service-account.playnanoo.com/api/v20240101/social/signin
  • Method: PUT
  • Authentication Required: No

Request Parameters

ParameterTypeRequiredDescription
account_tokenstringRequiredSocial login token (Apple ID Token)
account_typestringRequiredAccount type (PN_ACCOUNT_APPLE_ID = "APPLE ID")

Response Data

Res Structure

FieldTypeDescription
TokenFSerializeTokenDataToken information
PlayerFSerializePlayerDataPlayer information

FSerializeTokenData Structure

FieldTypeDescription
AccessTokenFStringAccess token
RefreshTokenFStringRefresh token

FSerializePlayerData Structure

FieldTypeDescription
UserUniqueIDFStringUser unique ID
OpenIDFStringOpen ID
NicknameFStringNickname
LinkedIDFStringLinked ID
LinkedTypeFStringLinked type
PurchaseCountint32Purchase count
PurchaseCurrencyCodeFStringPurchase currency code
PurchaseTotalPricedoubleTotal purchase amount
PurchaseVoidedCountint32Refund count
PurchaseVoidedCurrencyCodeFStringRefund currency code
PurchaseVoidedTotalPricedoubleTotal refund amount
CountryFStringCountry
TimezoneFStringTimezone
Offsetint32Time offset
JoinPeriodint32Join period

Unreal C++ Implementation

// AppleSignInExample.h
#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "AppleSignInExample.generated.h"

UCLASS()
class YOURPROJECT_API AAppleSignInExample : public AActor
{
GENERATED_BODY()

public:
AAppleSignInExample();

UFUNCTION(BlueprintCallable, Category = "PlayNANOO|Account")
void SignIn();

private:
void OnAppleSignInComplete(const FString& IdToken);
void SocialSignin(const FString& Token);
};

// AppleSignInExample.cpp
#include "AppleSignInExample.h"
#include "OnlineSubsystem.h"
#include "OnlineSubsystemApple.h"
#include "Interfaces/OnlineIdentityInterface.h"

AAppleSignInExample::AAppleSignInExample()
{
PrimaryActorTick.bCanEverTick = false;
}

void AAppleSignInExample::SignIn()
{
IOnlineSubsystem* OnlineSubsystem = IOnlineSubsystem::Get(APPLE_SUBSYSTEM);
if (OnlineSubsystem)
{
IOnlineIdentityPtr Identity = OnlineSubsystem->GetIdentityInterface();
if (Identity.IsValid())
{
FOnLoginCompleteDelegate LoginDelegate = FOnLoginCompleteDelegate::CreateLambda(
[this](int32 LocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& Error)
{
if (bWasSuccessful)
{
// Get Apple ID Token
IOnlineSubsystem* OnlineSubsystem = IOnlineSubsystem::Get(APPLE_SUBSYSTEM);
if (OnlineSubsystem)
{
IOnlineIdentityPtr Identity = OnlineSubsystem->GetIdentityInterface();
if (Identity.IsValid())
{
FString IdToken = Identity->GetAuthToken(LocalUserNum);
OnAppleSignInComplete(IdToken);
}
}
}
else
{
UE_LOG(LogTemp, Error, TEXT("Apple authentication failed: %s"), *Error);
}
}
);

Identity->AddOnLoginCompleteDelegate_Handle(0, LoginDelegate);
Identity->Login(0, FOnlineAccountCredentials());
}
}
}

void AAppleSignInExample::OnAppleSignInComplete(const FString& IdToken)
{
// Call SocialSignin API
SocialSignin(IdToken);
}

void AAppleSignInExample::SocialSignin(const FString& Token)
{
// SocialSignIn(Token, TEXT("APPLE ID"));
UE_LOG(LogTemp, Log, TEXT("Apple ID Token: %s"), *Token);
}

Usage

1. Start Apple Login

void UYourClass::StartAppleSignIn()
{
AAppleSignInExample* AppleSignIn = GetWorld()->SpawnActor<AAppleSignInExample>();
if (AppleSignIn)
{
AppleSignIn->SignIn();
}
}

Call the PlayNANOO API with the token received in the SocialSignin method after authentication:

New Login (SocialSignIn)

void UYourClass::SocialSignIn(const FString& Token, const FString& AccountType)
{
// First login with Apple account
// AccountType: "APPLE ID"
}
Reference
Online Subsystem Apple

To use Unreal Engine's Online Subsystem Apple, you must enable it in project settings and configure appropriate settings. Refer to the Unreal Engine official documentation for more details.