Skip to main content
Version: 1.10.x

Installing and Applying the SDK

Applying the AppGuard SDK


Download the AppGuard SDK

To apply the AppGuard SDK, the following essential files are required.
Please download the necessary configuration files for integration with the AppGuard SDK from the AppGuard Manager.

ItemDescription
AppGuard SDKProvided in the static framework format as AppGuardCore.xcframework
AppGuard Config FilesConfiguration files required for running AppGuard (appguard, appguard.crt, appguard.mf, appguard106000)

Applying the AppGuard SDK

  • Copy the downloaded AppGuardCore.xcframework file into your project.

  • Open your Xcode project and go to Project > TARGETS:ProjectName > Build Phases > Link Binary With Libraries, and click the Add[+] button at the bottom.

  • In the [Choose frameworks and libraries to add:] window, click the [Add Other] button at the bottom, then click the [Add Files...] button.

  • In the next window, select the AppGuardCore.xcframework file existing within your project and click the [Open] button.

  • The AppGuardCore.xcframework file has been added to [Link Binary With Libraries] in your project.

  • In your Xcode project, go to Project > TARGETS:ProjectName > Build Settings > Other Linker Flags and add the -lstdc++ and -lz options.


Applying the AppGuard Config Files

  • Copy the downloaded latest 4 config files (appguard, appguard.crt, appguard.mf, appguard106000) into an internal folder of your project.

  • Open your project and go to Project > TARGETS:ProjectName > Build Phases > Copy Bundle Resources, and click the Add[+] button at the bottom.

  • In the [Choose items to add:] window, click the [Add Other] button at the bottom.

  • In the next window, select the 4 config files existing within your project and click the [Open] button.

  • In the [Choose options for adding these files:] window, check [Destination:Copy items if needed] as "ON" and [Added folders:Create groups], then click the [Finish] button on the bottom right.

  • Confirm that the 4 config files have been added to [Copy Bundle Resources] in your project.


Objective-C

To use the AppGuard SDK, you must implement the essential APIs outlined below.

Essential API Implementation

To use the AppGuard SDK, you must implement the essential APIs outlined below.

Callback Functions Introduction

The AppGuard SDK provides callback functions to deliver data such as AppGuard's operational status and detected event information to the app. These callback functions are registered with the AppGuard SDK through the APPGUARD_INIT API.

typedef void (*PAPPGUARDAPPCALLBACK)(int type, int code, const char *pData);
static void APPGUARD_INIT(PAPPGUARDAPPCALLBACK);
caution

Callback functions must be implemented within the project that applies them, and passed as parameters when calling APPGUARD_INIT.


Implementing and Registering Callback Functions

Callback functions should be registered at the very beginning of the App's entry point. It is generally recommended to implement and register them in the AppDelegate source file.

AppDelegate.m
/**
* Declare callback functions for communication with the AppGuard SDK
* It is generally recommended to implement this at the top of the AppDelegate Source file.
*/

#import <AppGuardCore/AppGuard.h>
#import <AppGuardCore/AppGuardDefine.h>

static void AppGuardAppCallback(int type, int code, const char* desc)
{
if(type == APPGUARD_TYPE_KILL)
{
/**
* Notifies when the detection content is set to kill option by policy and requests for forced termination.
* If this notification message is detected, the app must be forcibly terminated.
* It is recommended to terminate the app after notifying through a message box.
*/
}
else if(type == APPGUARD_TYPE_S2AUTH_CALLBACK)
{
if(code == APPGUARD_TYPE_CSAUTH_SUCESS)
{
/**
* The server authentication process has succeeded.
* Please use the server authentication ID passed through the desc parameter
* to perform re-verification on the game server.
*
* desc: Server authentication ID
*/

}
else if(code == APPGUARD_TYPE_CSAUTH_FALSE)
{
/**
* The server authentication process has failed.
* Please use the server authentication ID passed through the desc parameter
* to perform re-verification on the game server.
*
* The failure of the server authentication process may be due to the client's network issues,
* so please make sure to proceed with re-verification through the game server.
*
* desc: Server authentication ID
*/
}
}
}

...

/**
* Register callback functions for communication with the AppGuard SDK
*
* The registration of callback functions is done using the APPGUARD_INIT API.
*
* It is recommended to implement the use of the APPGUARD_INIT API inside the didFinishLaunchingWithOption function of the AppDelegate.
*/
- (Bool)application:(UIApplication *)application didFinishLaunchingWithOption:(NSDictionary *) launchOptions {
// Use the APPGUARD_INIT API to register the callback function with the AppGuard SDK
APPGUARD_INIT(AppGuardAppCallback);
}

If you have reached this point, you have completed the basic setup required to use the AppGuard SDK. Please build and run your project to ensure that the AppGuard SDK is functioning correctly.

tip

For more detailed information about the APIs provided by the AppGuard SDK, please refer to the AppGuard SDK API Reference.

Swift

AppGuard Swift Interface Description

To use the AppGuard API, which is created in Objective-C, within a Swift-based Project, the Bridging Header method must be utilized. For the convenience of clients using the Objective-C-based AppGuard API in a Swift Project, the following three files are provided separately:

FilenameDescriptionLanguage
AppGuard-Bridging-Header.hBridging Header to integrate Swift and Objective-C modulesObjective-C
AppGuardWarpper.hDeclaration of the AppGuard API interfaceObjective-C
AppGuardWarpper.mmImplementation of calling the AppGuard API interfaceObjective-C

AppGuard Swift Interface Bridging Application

  • Copy the three files (AppGuard-Bridging-Header.h, AppGuardWarpper.h, AppGuardWarpper.mm) from the downloaded AppGuard Swift interface /appguard_swift_interfaces folder to the project's internal folder (Project/).

  • Add the three copied AppGuard Swift interface files to the project by [Drag & Drop].

  • Click the [Finish] button at the bottom of the [Choose options for adding these files:] window.

  • In the [Would you like to configure an Objective-C bridging header?] window, click the [Don't Create] button.

  • Verify that the three AppGuard Swift interface files (AppGuard-Bridging-Header.h, AppGuardWarpper.h, AppGuardWarpper.mm) have been added to the project.

  • Add the path value $(SRCROOT)/MyProject/AppGuard-Bridging-Header.h to the Project > TARGETS:Project Name > Build Settings > Swift Compiler - General > Objective-C Bridging Header item.

info

If the above steps have been successfully completed, your Swift Project is now ready to use the AppGuard API.


Essential Application of AppGuard Swift API


Callback Function Introduction

In the case of a Swift Project, the APPGUARDGAMECALLBACK function is defined at the top of the AppGuardWarpper.mm file. This function detects and reports abnormal behavior caused by malicious users. If the detection includes conditions set by the security policy in the admin page that require forced termination, the app is notified of such content.

By applying the same as the sample code below, you can handle the receipt of detection and reporting content.

AppGuardWarpper.mm
// AppGuardWarpper.mm

static void APPGUARDGAMECALLBACK(int type, int code, const char* desc)
{
if(type == APPGUARD_TYPE_KILL)
{
/**
* Notifies when the detection content is set to the kill option by policy and requests for forced termination.
* If this notification message is detected, the App must be forcibly terminated.
* It is recommended to terminate the app after notifying through a message box.
*/
}
else if(type == APPGUARD_TYPE_S2AUTH_CALLBACK)
{
if(code == APPGUARD_TYPE_CSAUTH_SUCCESS)
{
/**
* The server authentication process has been successful.
* Please use the server authentication ID provided through the desc parameter
* to perform a re-verification operation on the game server.
*
* desc: Server authentication ID
*/

}
else if(code == APPGUARD_TYPE_CSAUTH_FALSE)
{
/**
* The server authentication process has failed.
* Please use the server authentication ID provided through the desc parameter
* to perform a re-verification operation on the game server.
*
* The failure of the server authentication process may be due to client's network issues,
* so please be sure to proceed with a re-verification operation through the game server.
*
* desc: Server authentication ID
*/
}
}
}

tip

Please implement the termination message handling logic inside the APPGUARDGAMECALLBACK() function.

caution

When releasing the actual service, please be sure to remove the log output functions inside the APPGUARDGAMECALLBACK() function.


Callback Function Registration

This is an essential API function that handles the operation of AppGuard and communication with the AppGuard SDK. Please ensure to call the AppGuard initialization function, APPGUARD_INIT API, within the application function of AppDelegate.swift exactly as in the sample code below. This represents the registration of callback functions in a Swift Project.

AppDelegate.swift
// AppDelegate.swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions:
[UIApplication.LaunchOptionsKey: Any]?) -> Bool {
//* Use the APPGUARD_INIT API to register the callback function with the AppGuard SDK
let obj = AppGuardWarpper()
obj.initAppGuard()

return true
}
info

If you have completed the above steps correctly, you have finished all the preparations needed to use AppGuard in your Swift Project.

tip

For more detailed information about the APIs provided by the AppGuard SDK, please refer to the AppGuard SDK API Reference.