PLUG Unreal Guide

Quick Start

Download latest version

Copy the Plugins/CafeSDKPlugin folder that is included in the sample project to the project. Then, apply the development environment settings as indicated below, depending on the operating system.

2.1 Android Settings

Copy the following file and folder from the Build/Android folder included in the sample project to the project.

  • ManifestApplicationAdditions.txt

  • JavaLibs 폴

2.2 iOS 설정

Add project settings to the DefaultEngine.ini file as indicated below.

AdditionalLinkerFlags=-ObjC
AdditionalShippingLinkerFlags=-ObjC
AdditionalPlistData=<key>CFBundleURLTypes</key> <array>    <dict>            <key>CFBundleURLSchemes</key>           <array>               <string>gLinkSample</string>        </array>    </dict>   </array><key>NSAppTransportSecurity</key><dict><key>NSAllowsArbitraryLoads</key><true/></dict> <key>LSApplicationQueriesSchemes</key><array><string>navercafe</string><string>naversearchapp</string><string>naversearchthirdlogin</string></array>    <key>CFBundleURLTypes</key><array><dict><key>CFBundleTypeRole</key><string>Editor</string><key>CFBundleURLSchemes</key><array><string>gLinkSample</string></array></dict></array><key>NSPhotoLibraryUsageDescription</key><string>Access your photos to create a post.</string>

Add framework settings to the Build.cs file as indicated below.

if (Target.Platform == UnrealTargetPlatform.IOS)
{
    // Add framework
    PublicAdditionalFrameworks.Add(
        new UEBuildFramework(
            "NaverCafeSDK",
            "../../ThirdPartyFrameworks/iOS/NaverCafeSDK.embeddedframework.zip",
            "Resources/NaverCafeSDK.bundle"
        )
    );
    PublicAdditionalFrameworks.Add(
        new UEBuildFramework(
            "NaverLogin",
            "../../ThirdPartyFrameworks/iOS/NaverLogin.embeddedframework.zip",
            "Resources/NaverAuth.bundle"
        )
    );
    PublicAdditionalFrameworks.Add(
        new UEBuildFramework(
            "AFNetworking",
            "../../ThirdPartyFrameworks/iOS/AFNetworking.embeddedframework.zip"
        )
    );
    PublicAdditionalFrameworks.Add(
        new UEBuildFramework(
            "SDWebImage",
            "../../ThirdPartyFrameworks/iOS/SDWebImage.embeddedframework.zip"
        )
    );
    PublicAdditionalFrameworks.Add(
        new UEBuildFramework(
            "FLAnimatedImage",
            "../../ThirdPartyFrameworks/iOS/FLAnimatedImage.embeddedframework.zip"
        )
    );
    PublicAdditionalFrameworks.Add(
        new UEBuildFramework(
            "ApiGateway",
            "../../ThirdPartyFrameworks/iOS/ApiGateway.embeddedframework.zip"
        )
    );

    PublicFrameworks.AddRange(
        new string[] {
            "UIKit",
            "Foundation",
            "MediaPlayer",
            "SystemConfiguration",
            "Security",
            "MobileCoreServices",
            "GameKit",
            "AssetsLibrary",
        }
    );
    PublicWeakFrameworks.Add("ReplayKit");
}

3. Initialization

Initialize PLUG SDK according to the language that is being supported, as explained below.

3.1 PLUG SDK initialization (only supports Korean - Naver cafe)

When initializing PLUG SDK that only supports Korean, set the initialization settings like indicated below.

  • Client ID and Client Secret received when registering an application on the login developer center using a Naver ID

  • Cafe ID received by opening a Naver cafe

  • URL scheme entered when registering an application on the login developer center using a Naver ID

if (FCafeSDKPluginModule::IsAvailable())
{
    UCafeSdkBlueprintLibrary::Init("U5ZHoj_OStOHOJ8mec_s", "piPHPA9i4E", 28334359);
}

3.2 PLUG SDK initialization (only supports a foreign language)

When initializing PLUG SDK that only supports foreign languages, set the initialization setting like indicated below.

  • Consumer key and consumer secret received by registering for PLUG SDK partnership

  • Community No. and lounge No. received by registering for PLUG SDK partnership

  • consumerKey: Consumer key received by opening the community

  • consumerSecretKey: Consumer secret key received by opening the community

  • communityNo: Community No. received by opening the community

  • loungeNo: Lounge No. received by opening the lounge

if (FCafeSDKPluginModule::IsAvailable())
{
    /**
     * @param consumerKey       
     * @param consumerSecretKey 
     * @param communityNo      
     * @param loungeNo                          
     */
     UCafeSdkBlueprintLibrary::InitGlobal("PLUGKEY", "PLUGSECRET", 1, 58);
}

4. Start PLUG SDK

Run PLUG SDK after initialization is complete.

4.1 StartHome() method

The StartHome() method is used for starting PLUG SDK.

UFUNCTION(BlueprintCallable, Category = "Naver CafeSdk")
static void StartHome();

4.2 ShowWidgetWhenUnloadSdk() method

This is the method used to reveal the widget on the screen when fold button is pressed on PLUG SDK.

UFUNCTION(BlueprintCallable, Category = "Naver CafeSdk")
static void ShowWidgetWhenUnloadSdk(bool bUse);

4.3 SetUseVideoRecord() 메서드

The SetUseVideoRecord() method is used for revealing the video record button on the PLUG SDK widget (iOS 9.0 or above).

UFUNCTION(BlueprintCallable, Category = "Naver CafeSdk")
static void SetUseVideoRecord(bool bUse);

4.4 Callback delegate

Apply a callback delegate setting to deliver user events that have occurred in PLUG SDK with the callback function.

It is a method that is called by a using callback delegate and it is used for starting / closing PLUG SDK, writing posts (image / video attachment), joining, writing comments, and voting.

static FOnCafeSdkStarted OnCafeSdkStarted;
static FOnCafeSdkStopped OnCafeSdkStopped;
static FOnCafeSdkClickAppSchemeBanner OnCafeSdkClickAppSchemeBanner;
static FOnCafeSdkJoined OnCafeSdkJoined;
static FOnCafeSdkPostedArticle OnCafeSdkPostedArticle;
static FOnCafeSdkPostedComment OnCafeSdkPostedComment;
static FOnCafeSdkRecordFinish OnCafeSdkRecordFinish;
static FOnCafeSdkDidVote OnCafeSdkDidVote;

Initialization of a plugin that supports the global community and a domestic Naver cafe

When it supports both the global community and a domestic Naver cafe, the initialization setting should be set for both the global community and domestic Naver cafes.

Default channel settings

Settings for the default channel, which is the community for each language on the plugin, is applied with the language that is set on the device.

The following is an example for setting a certain language on the default channel.

void ACafeSDKSampleProjectGameMode::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage)
{
    AGameMode::InitGame(MapName, Options, ErrorMessage);
    if (FCafeSDKPluginModule::IsAvailable())
    {
        UCafeSdkBlueprintLibrary::SetChannelCode("en");
        ...
    }
}

Start / Close

Start or close the plugin while a certain tab is selected.

StartHome() method

Start the plugin while home tab is selected.

static void StartHome()

The following is an example of the StartHome() method.

   /**
   * Start with the home tab
   */
    UFUNCTION(BlueprintCallable, Category = "Naver CafeSdk")
    static void StartHome();

Horizontal mode, vertical mode

The plugin supports both horizontal and vertical modes.

Android

In the Android environment, horizontal and vertical modes are automatically applied without having to apply the setting separately.

iOS

In the Android environment, horizontal and vertical modes are automatically applied without having to apply the setting separately.

The following is an example of using the horizontal mode on the plugin.

// Default value is YES
// Horizontal mode
[[NCSDKManager getSharedInstance] setOrientationIsLandscape:YES];

The following is an example of using the vertical mode on the plugin.

// Vertical mode
[[NCSDKManager getSharedInstance] setOrientationIsLandscape:NO];

Adjust transparency

If you adjust transparency using the adjustment slider on the upper left side of the plugin screen, you can use the game and the cafe at the same time.

transparency

Description

Alpha value 100%

deliver touch events to the plugin

Alpha value 100% below

deliver touch events to the game

Android

You can set the setTransparentable() method to enable the transparency adjustment slider in the Android environment.

public static void setTransparentable(Activity activity, boolean isTransparentable)

If you set "true" for the isTransparentable parameter value, you can use the transparency adjustment slider (default value: true).

The following is an example of using the transparency adjustment slider.

  /**
   * You can apply setting for using transparency adjustment slider.
   *
   * Boolean type value for enabling @param isTransparentable transparency adjustment  
   */
  Glink.setTransparentable(activity, true)

iOS

Apply the disableTransparentSlider: method setting to use transparency adjustment slider in iOS environment.

(void)disableTransparentSlider:(BOOL)disable;

If you set YES as the disable parameter value, you can use the transparency adjustment slider (default value: YES).

The following is an example of using the transparency adjustment slider.

/*
 Remove the function for adjusting transparency
 default : YES
 */
// Use the transparency function
[[NCSDKManager getSharedInstance] disableTransparentSlider:YES];

The following is an example of not using the transparency adjustment slider.

//Remove the transparency function
[[NCSDKManager getSharedInstance] disableTransparentSlider:NO];

Widget

A widget is an element that is automatically displayed on the screen when the fold button is pressed on the plugin. You can use the plugin anywhere in the game by using a widget.

Widget display

You can apply the showWidgetWhenUnloadSDK() method setting in order to display the widget when the fold button is pressed on the plugin.

static void ShowWidgetWhenUnloadSdk(bool show)

If you set true on useWidget parameter value, widget is displayed when plug window is folded (default value: true).

The following is an example of displaying the widget.

  /**
   * You can decide whether or not to display the widget when the plugin window is folded.
   *
   * Boolean type value for displaying @param useWidget widget
   */
    UFUNCTION(BlueprintCallable, Category = "Naver CafeSdk")
    static void ShowWidgetWhenUnloadSdk(bool bUse)

Default position settings for the widget

When the widget is first run, it is displayed on the center-left part of the screen. If you wish to set the default position settings when the widget is first run, use the setWidgetStartPosition() method.

However, when the widget is run again after the user has moved the widget, the widget will be displayed in the position where the user last moved it.

static void SetWidgetStartPosition(bool bIsLeft, int32 HeightPercentage);

The following is an example for setting the widget's default position to 20% from top, on the right side of the screen.

    /**
    * Apply default position setting for widget.
    * isLeft: If the value is true, it is displayed on the left. If the value is false, it is displayed on the right.
    * heightPercentage: You can designate the vertical position using %.
    **/
  UCafeSdkBlueprintLibrary::SetWidgetStartPosition(false, 20);

Screen capture

You can capture the game screen by pressing the screen capture button on the widget.

Screen capture button

Screen capture function is run by registering widget screen capture button click listener.

Android

In Android environment, widget screen capture button click listener is registered on following callback function.

static FOnScreenshotCaptured& OnScreenshotCaptured()

The following is an example

  /**
   * Register callback and screen capture
   */
void ACafeSDKSampleProjectGameMode::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage)
{
...        
        GEngine->GameViewport->OnScreenshotCaptured().AddUObject(this,
            &ACafeSDKSampleProjectGameMode::OnScreenshotCaptured);
...            
    }
}


  /**
   * Set widget screen capture callback listener
   */
void ACafeSDKSampleProjectGameMode::OnScreenshotCaptured(int32 Width, int32 Height, const TArray<FColor>& Colors)
{
    auto Bitmap = TArray<FColor>(Colors);
    GetHighResScreenshotConfig().MergeMaskIntoAlpha(Bitmap);

    FIntRect SourceRect(0, 0, GScreenshotResolutionX, GScreenshotResolutionY);
    if (GIsHighResScreenshot)
    {
        SourceRect = GetHighResScreenshotConfig().CaptureRegion;
    }

    FString ScreenshotName = FScreenshotRequest::GetFilename();

    if (!FPaths::GetExtension(ScreenshotName).IsEmpty())
    {
        ScreenshotName = FPaths::GetBaseFilename(ScreenshotName, false);
        ScreenshotName += TEXT(".png");
    }

    // Save the contents of the array to a png file.
    TArray<uint8> CompressedBitmap;
    FImageUtils::CompressImageArray(Width, Height, Bitmap, CompressedBitmap);
    FFileHelper::SaveArrayToFile(CompressedBitmap, *ScreenshotName);

#if PLATFORM_ANDROID
    extern FString GFilePathBase;
    FString BasePath = GFilePathBase + TEXT("/UE4Game/") + FApp::GetGameName() + TEXT("/") + FApp::GetGameName() + TEXT("/Saved/Screenshots/");
    FString ScreenshotPath = FPaths::ConvertRelativePathToFull(BasePath, ScreenshotName);
    UCafeSdkBlueprintLibrary::StartImageWrite(TEXT("file://") + ScreenshotPath);
#elif PLATFORM_IOS
    FString Result = ScreenshotName;
    Result.ReplaceInline(TEXT("../"), TEXT(""));
    Result.ReplaceInline(TEXT(".."), TEXT(""));
    Result.ReplaceInline(FPlatformProcess::BaseDir(), TEXT(""));

    FString WritePathBase = FString([NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]) + TEXT("/");
    UCafeSdkBlueprintLibrary::StartImageWrite(WritePathBase + Result);
#endif
}

Screen capture settings

You can use the setUseWidgetScreenShot() method to enable screen capture functionality.

static void SetUseScreenshot(boolean use);

If you set useScreenShot parameter value as true, screen capture button is displayed on the widget (default value: true).

The following is an example of not using screen capture function.

/**
* Screen capture button is not displayed on the widget.
*/
UCafeSdkBlueprintLibrary::SetUseScreenshot(true);

Video recording

If you press the video recording button, you can record the game screen while playing the game.

Tasks that should be processed when video recording is complete are carried out by registering OnCafeSdkRecordFinish, which is the recording ended listener

static FOnCafeSdkRecordFinish OnCafeSdkRecordFinish;

The following is an example of using the recording ended listener.

  /**
   * Register the recording ended callback.
   */
void ACafeSDKSampleProjectGameMode::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage)
{
...        
        FCafeSDKPluginModule::OnCafeSdkRecordFinish.AddUObject(this,
            &ACafeSDKSampleProjectGameMode::OnCafeSdkRecordFinish);
...            
    }
}

  /**
   * Set the recording ended listener.
   */
void ACafeSDKSampleProjectGameMode::OnCafeSdkRecordFinish(const FString& FileUri)
{
    UCafeSdkBlueprintLibrary::StartVideoWrite(FileUri);
}

Video recording

If you press the video recording button, you can record the game screen while playing the game.

  • The video recording function is supported on Android 5.0 or above.

  • Video recording functionality is supported on iOS 9.0 or above.

Video recording settings

You can use the setUseVideoRecord() method to enable the video recording function.

static void SetUseVideoRecord(bool use)

If you set the use parameter value as true, the video recording button will be displayed on the widget (default value: false).

The video recording button is not displayed on the widget for devices using Android 5.0 or below and iOS 9.0 or below, even if you set the use parameter value as true.

The following is an example of using the video recording function.

/**
   * You can decide whether to use video recording function.
   *
   * Boolean type value for enabling @param use video recording function
   */
...
    UCafeSdkBlueprintLibrary::SetUseVideoRecord(true);
...

Recording ended callback listener

Tasks that should be processed when video recording is ended are carried out by registering the OnCafeSdkRecordFinish listener.

static FOnCafeSdkRecordFinish OnCafeSdkRecordFinish;

The following is an example of using the recording ended listener.

/**
   * Register the recording ended callback.
   */
void ACafeSDKSampleProjectGameMode::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage)
{
...        
        FCafeSDKPluginModule::OnCafeSdkRecordFinish.AddUObject(this,
            &ACafeSDKSampleProjectGameMode::OnCafeSdkRecordFinish);
...            
    }
}

  /**
   * Set the recording ended listener.
   */
void ACafeSDKSampleProjectGameMode::OnCafeSdkRecordFinish(const FString& FileUri)
{
    UCafeSdkBlueprintLibrary::StartVideoWrite(5, TEXT("subject"), TEXT("text"), FileUri);
}

App scheme processing

When you press the banner image that is displayed on the home screen of the game plugin, you can go to the App scheme to run game functions.

You can register the banner image for moving to the App scheme from the cafe management menu.

Android

If you set OnCafeSdkClickAppSchemeBanner in the Android environment while there is a banner image that goes to App scheme, the App scheme processing function can be operated when a touch event has occurred.

static FOnCafeSdkClickAppSchemeBanner OnCafeSdkClickAppSchemeBanner;

The following is an example of using a listener to process the App scheme.

void ACafeSDKSampleProjectGameMode::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage)
{
...
        FCafeSDKPluginModule::OnCafeSdkClickAppSchemeBanner.AddUObject(this,
            &ACafeSDKSampleProjectGameMode::OnCafeSdkClickAppSchemeBanner);
...        
    }
}

// App scheme touch listener settings.
void ACafeSDKSampleProjectGameMode::OnCafeSdkClickAppSchemeBanner(const FString& AppScheme)
{
    FString Message = FString::Printf(TEXT("OnCafeSdkClickAppSchemeBanner: %s"), *AppScheme);
    ShowMessage(Message);
}

iOS

When pressing a banner image that goes to App scheme in the iOS environment, set the App delegate on openURL: method on the App delegate to process the App scheme as indicated below.

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
...
// Process the App scheme that is registered on the management menu from the App delegate.
//ex : gLinkSample://test
    if ([[url scheme] isEqualToString:@"gLinkSample"]) {
        if ([[url host] isEqualToString:@"test"]) {
            //todo
        }
    }
...
}

Callback listener

Register the callback listener to process events that have occurred in the plugin.

The callback listener is registered on the Unreal Naver cafe plugin library as indicated below.

void ACafeSDKSampleProjectGameMode::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage)
{
    AGameMode::InitGame(MapName, Options, ErrorMessage);

    if (FCafeSDKPluginModule::IsAvailable())
    {
        UCafeSdkBlueprintLibrary::Init("U5ZHoj_OStOHOJ8mec_s", "piPHPA9i4E", 28334359);

        // Start plugin
        FCafeSDKPluginModule::OnCafeSdkStarted.AddUObject(this,
            &ACafeSDKSampleProjectGameMode::OnCafeSdkStarted);

        // Close plugin
        FCafeSDKPluginModule::OnCafeSdkStopped.AddUObject(this,
            &ACafeSDKSampleProjectGameMode::OnCafeSdkStopped);

        // App scheme
        FCafeSDKPluginModule::OnCafeSdkClickAppSchemeBanner.AddUObject(this,
            &ACafeSDKSampleProjectGameMode::OnCafeSdkClickAppSchemeBanner);

        // Join cafe
        FCafeSDKPluginModule::OnCafeSdkJoined.AddUObject(this,
            &ACafeSDKSampleProjectGameMode::OnCafeSdkJoined);

        // Register post
        FCafeSDKPluginModule::OnCafeSdkPostedArticle.AddUObject(this,
            &ACafeSDKSampleProjectGameMode::OnCafeSdkPostedArticle);

        // Register comment
        FCafeSDKPluginModule::OnCafeSdkPostedComment.AddUObject(this,
            &ACafeSDKSampleProjectGameMode::OnCafeSdkPostedComment);

        // Register vote
        FCafeSDKPluginModule::OnCafeSdkDidVote.AddUObject(this,
            &ACafeSDKSampleProjectGameMode::OnCafeSdkDidVote);

        // Widget video recording ended
        FCafeSDKPluginModule::OnCafeSdkRecordFinish.AddUObject(this,
            &ACafeSDKSampleProjectGameMode::OnCafeSdkRecordFinish);

        // Screenshot
        GEngine->GameViewport->OnScreenshotCaptured().AddUObject(this,
            &ACafeSDKSampleProjectGameMode::OnScreenshotCaptured);
    }
}

Plugin startup listener

OnCafeSdkStarted is a callback listener that processes events that have occurred when the plugin starts.

static FOnCafeSdkStarted OnCafeSdkStarted;

The following is an example of using the plugin startup listener.

   // Plugin startup listener settings
void ACafeSDKSampleProjectGameMode::OnCafeSdkStarted()
{
    ShowMessage("OnCafeSdkStarted");
}

Plugin closing listener

OnCafeSdkStopped is a callback listener that processes events that have occurred when the plugin is closed.

static FOnCafeSdkStopped OnCafeSdkStopped;

The following is an example of using the plugin closing listener.

// Plugin closing listener settings
void ACafeSDKSampleProjectGameMode::OnCafeSdkStopped()
{
    ShowMessage("OnCafeSdkStopped");
}

App scheme listener

OnCafeSdkClickAppSchemeBanner is a callback listener that processes events that have occurred when pressing a banner image that goes to the App scheme in an Android environment.

static FOnCafeSdkClickAppSchemeBanner OnCafeSdkClickAppSchemeBanner;

The following is an example of using the App scheme listener.

// App scheme listener settings
void ACafeSDKSampleProjectGameMode::OnCafeSdkClickAppSchemeBanner(const FString& AppScheme)
{
    FString Message = FString::Printf(TEXT("OnCafeSdkClickAppSchemeBanner: %s"), *AppScheme);
    ShowMessage(Message);
}

Cafe registration listener

OnCafeSdkJoined is a callback listener that processes events that have occurred when game users join the cafe on the plugin.

static FOnCafeSdkJoined OnCafeSdkJoined;

The following is an example of using the cafe registration listener.

// Cafe registration listener settings
void ACafeSDKSampleProjectGameMode::OnCafeSdkJoined()
{
    ShowMessage("OnCafeSdkJoined");
}

Post registration listener

OnCafeSdkPostedArticle is a callback listener that processes events that have occurred when users register posts on the plug.

static FOnCafeSdkPostedArticle OnCafeSdkPostedArticle;

The following is an example of using the post registration listener.

    /** Post registration listener settings
     * Menuld is where @param menuId posts are registered
     * The number of image files in which @param imageCount is attached
     * The number of video files in which @param videoCount is attached
     **/

void ACafeSDKSampleProjectGameMode::OnCafeSdkPostedArticle(int32 MenuId, int32 ImageCount, int32 VideoCount)
{
    FString Message = FString::Printf(TEXT("OnCafeSdkPostedArticle: %d, %d, %d"), MenuId, ImageCount, VideoCount);
    ShowMessage(Message);
}

Comment registration listener

OnCafeSdkPostedComment is a callback listener that processes events that have occurred when users register comments on posts in the plugin.

static FOnCafeSdkPostedComment OnCafeSdkPostedComment;

The following is an example of using the comment registration listener.

   // Comment registration listener settings
void ACafeSDKSampleProjectGameMode::OnCafeSdkPostedComment(int32 ArticleId)
{
    FString Message = FString::Printf(TEXT("OnCafeSdkPostedComment: %d"), ArticleId);
    ShowMessage(Message);
}

Voting ended listener

OnCafeSdkDidVote is a callback method that processes events that have occurred when users vote on comments in the plugin.

static FOnCafeSdkDidVote OnCafeSdkDidVote;

The following is an example of using the voting ended listener.

   // Voting ended listener settings
void ACafeSDKSampleProjectGameMode::OnCafeSdkDidVote(int32 ArticleId)
{
    FString Message = FString::Printf(TEXT("OnCafeSdkDidVote: %d"), ArticleId);
    ShowMessage(Message);
}

Screen capture button click listener

OnScreenshotCaptured is callback listener that processes events that have occurred when users pressed the screen capture button on the widget. Refer to "widget” for details about the screen capture button.

static FOnScreenshotCaptured& OnScreenshotCaptured()

The following is an example of using the screen capture button click listener. By using the screen capture function on the callback listener, you can capture the screen when you press the screen capture button.

  /**
   * Set the widget screen capture button click listener.
   */
void ACafeSDKSampleProjectGameMode::OnScreenshotCaptured(int32 Width, int32 Height, const TArray<FColor>& Colors)
{
    auto Bitmap = TArray<FColor>(Colors);
    GetHighResScreenshotConfig().MergeMaskIntoAlpha(Bitmap);

    FIntRect SourceRect(0, 0, GScreenshotResolutionX, GScreenshotResolutionY);
    if (GIsHighResScreenshot)
    {
        SourceRect = GetHighResScreenshotConfig().CaptureRegion;
    }

    FString ScreenshotName = FScreenshotRequest::GetFilename();

    if (!FPaths::GetExtension(ScreenshotName).IsEmpty())
    {
        ScreenshotName = FPaths::GetBaseFilename(ScreenshotName, false);
        ScreenshotName += TEXT(".png");
    }

    // Save the contents of the array to a png file.
    TArray<uint8> CompressedBitmap;
    FImageUtils::CompressImageArray(Width, Height, Bitmap, CompressedBitmap);
    FFileHelper::SaveArrayToFile(CompressedBitmap, *ScreenshotName);

#if PLATFORM_ANDROID
    extern FString GFilePathBase;
    FString BasePath = GFilePathBase + TEXT("/UE4Game/") + FApp::GetGameName() + TEXT("/") + FApp::GetGameName() + TEXT("/Saved/Screenshots/");
    FString ScreenshotPath = FPaths::ConvertRelativePathToFull(BasePath, ScreenshotName);
    UCafeSdkBlueprintLibrary::StartImageWrite(-1, "", "", TEXT("file://") + ScreenshotPath);
#elif PLATFORM_IOS
    FString Result = ScreenshotName;
    Result.ReplaceInline(TEXT("../"), TEXT(""));
    Result.ReplaceInline(TEXT(".."), TEXT(""));
    Result.ReplaceInline(FPlatformProcess::BaseDir(), TEXT(""));

    FString WritePathBase = FString([NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]) + TEXT("/");
    UCafeSdkBlueprintLibrary::StartImageWrite(-1, "", "", WritePathBase + Result);
#endif
}

Recording ended listener

OnCafeSdkRecordFinish is a callback listener that processes events that have occurred when video recording is ended on the plugin.

static FOnCafeSdkRecordFinish OnCafeSdkRecordFinish;

The following is an example of using the recording ended listener.

  /** 
   * You can decide whether or not to use the video recording function
   *
   * URI for file route where @param uri video is stored
   */

void ACafeSDKSampleProjectGameMode::OnCafeSdkRecordFinish(const FString& FileUri)
{
    UCafeSdkBlueprintLibrary::StartVideoWrite(5, TEXT("subject"), TEXT("text"), FileUri);
}

Game ID linkage

By linking the user’s game ID and cafe ID, they can be managed. You can check for the list of linked game ID and cafe IDs from cafe management menu. In order to link a game ID and cafe ID, the syncGameUserId() method should be used.

static void SyncGameUserId(FString GameUserId)

The following is an example of linking the game ID and cafe ID.

  /**
   * Link the game ID and cafe ID.
   *
   * @param gameUserId game ID
   */
void ACafeSDKSampleProjectGameMode::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage)
{
...    
   UCafeSdkBlueprintLibrary::SyncGameUserId("userGameID");
...
}

Change theme color

You can change the theme color of the plugin.

In order to change the theme color, the setThemeColor() method is used.

/** 
* The default value for the ThemeColorCSSString parameter is ‘#00c73c.’
* The default value for tabBackgroundColorCSSString parameter is ‘#44484e.’
* It is recommended that you use the default value for the tabBackgroundColorCSSString parameter.
**/


void UCafeSdkBlueprintLibrary::SetThemeColor(FString ThemeColorCSSString, FString TabBackgroundColorCSSString)
  • themeColorCSSString: The default color that is used on the theme (default value: #00c73c)backgroundCSSString: the background color for the tab menu (default value: #44484e). It is recommended that you use the default value.

Caution Do not apply alpha values for the CSS color value.

  • Correct example: #ff9800

  • Incorrect example: #e2ff9800

The following is an example of changing the theme color.

UCafeSdkBlueprintLibrary::SetThemeColor("#00c73c", "#44484e");

Naver login

Enable login with Naver ID in the application.

  • The NaverIdLoginBlueprintLibrary.h file is used for the Naver login function.

Init() method

Use the following initialization information to initialize the Naver login functionality.

  • Client ID received when registering application on the login developer center using Naver IDClient secret received when registering application on the login developer center using Naver ID

The following is an example of initializing the Naver login function.

    UNaverIdLoginBlueprintLibrary::Init("197CymaStozo7x5r2qR5", "evCgKH1kJL");

Login() method

Login with Naver ID.

    UNaverIdLoginBlueprintLibrary::Login();

Apply delegate processing for an event that has occurred after login is complete.

    FCafeSDKPluginModule::OnLoggedIn.AddUObject(this,
            &ACafeSDKSampleProjectGameMode::OnCafeSdkLoggedIn);

    void ACafeSDKSampleProjectGameMode::OnCafeSdkLoggedIn(bool bSuccess) {
        // handle event.
    }

Logout() method

Logout

    UNaverIdLoginBlueprintLibrary::Logout();

IsLogin() method

Check login status.

    UNaverIdLoginBlueprintLibrary::IsLogin();

GetProfile() method

Search for logged in user’s basic information (mail address, nickname, profile picture, birthday, age).

    UNaverIdLoginBlueprintLibrary::GetProfile();

Register listener for the information you wish to search for.

    FCafeSDKPluginModule::OnGetProfile.AddUObject(this,
        &ACafeSDKSampleProjectGameMode::OnCafeSdkGetProfile);

    void ACafeSDKSampleProjectGameMode::OnCafeSdkGetProfile(const FString& JsonString) {
        // handle event.
    }

Last updated