리포지토리에 연결
GitHub

앱스플라이어 Epic C++ SDK 연동

앱스플라이어는 크로스 플랫폼 어트리뷰션, 모바일 및 웹 분석, 딥링킹, 사기 탐지, 개인 정보 관리 및 보존 등을 포함하여 실제 문제를 해결하는 강력한 도구를 제공하여 게임 마케터가 더 나은 결정을 내릴 수 있도록 지원합니다.

게임 어트리뷰션을 위해서는 게임이 HTTPS를 통해 앱스플라이어 API와 통신하고 첫 번째 열기, 연속 세션 및 인앱이벤트와 같은 사용자 활동을 리포트해야 합니다. 예를 들어 구매 이벤트입니다.
C++에서 사용자 활동을 리포트하는 코드를 통합하기 위한 참조로 이 샘플 앱을 사용하는 것이 좋습니다. 참고: 다음 샘플 코드는 현재 Windows 환경에서만 지원됩니다.

Prerequisites

vcpkg openssl & nlohmann-json packages:

vcpkg install curl:x86-windows
vcpkg install nlohmann-json:x86-windows
vcpkg install openssl:x86-windows

AppsflyerLauncherModule - 인터페이스

AppsflyerLauncherModule.happsflyer-module 폴더에 있으며 앱스플라이어 서버에 연결하고 이벤트를 리포트하는 데 필요한 코드 및 논리가 포함되어 있습니다.

Init

이 메서드는 API 키와 앱 ID를 수신하고 앱스플라이어 모듈을 초기화합니다.

Method signature

void Init(const char* devkey, const char* appID)

Usage:

AppsflyerLauncherModule()->Init(<< DEV_KEY >>, << APP_ID >>);

Arguments:

Start

이 메서드는 앱스플라이어에 first open/session 요청을 보냅니다.

Method signature

void Start(bool skipFirst = false)

Usage:

// without the flag
AppsflyerLauncherModule()->Start();

// with the flag
bool skipFirst = [SOME_CONDITION];
AppsflyerLauncherModule()->Start(skipFirst);
void Stop()

Usage:

// Starting the SDK
AppsflyerLauncherModule()->Start();
// ...
// Stopping the SDK, preventing further communication with AppsFlyer
AppsflyerLauncherModule()->Stop();

LogEvent

이 메서드는 이벤트 이름과 JSON 객체를 수신하고 앱스플라이어에 인앱이벤트를 보냅니다.

Method signature

void LogEvent(std::string event_name, json event_values)

Usage:

json event_values = { {"af_currency", "USD"}, {"af_price", 6.66}, {"af_revenue", 24.12} };
std::string event_name = "af_purchase";
AppsflyerLauncherModule()->LogEvent(event_name, event_values);

참고: JSON을 사용하려면 다음 가져오기를 사용해야 합니다.

#include <nlohmann/json.hpp>
using json = nlohmann::json;

SetCustomerUserId

Setting your own customer ID enables you to cross-reference your own unique ID with AppsFlyer’s unique ID and other devices’ IDs.
This ID is available in raw-data reports and in the Postback APIs for cross-referencing with your internal IDs.
Can be used only before calling Start().

Method signature

void SetCustomerUserId(std::string cuid)

Usage:

AppsflyerLauncherModule()->Init(DEV_KEY, APP_ID);
AppsflyerLauncherModule()->SetCustomerUserId("Test-18-9-23");
AppsflyerLauncherModule()->Start();

OnCallbackSuccess, OnCallbackFailure

상기의 메서드는 성공/실패 시 원하는 작업에 대한 자리 표시자입니다.
각 함수 내에서 컨텍스트의 switch case를 사용하여 다양한 유형의 이벤트를 처리할 수 있습니다("FIRST_OPEN_REQUEST", "SESSION_REQUEST", "INAPP_EVENT_REQUEST").

Method signature

void OnCallbackSuccess(long responseCode, uint64 context)
void OnCallbackFailure(long responseCode, uint64 context)

GetAppsFlyerUID

앱스플라이어의 고유 기기 ID를 가져옵니다. SDK는 앱 설치 시 앱스플라이어의 고유 기기 ID를 생성합니다. SDK가 시작되면 이 ID가 첫 번째 앱 인스톨의 ID로 기록됩니다.

Method signature

std::string GetAppsFlyerUID()

Usage:

AppsflyerLauncherModule()->GetAppsFlyerUID();

IsInstallOlderThanDate

This method receives a date string and returns true if the game exe modification date is older than the date string. The date string format is: "2023-January-01 23:12:34"

Method signature

bool IsInstallOlderThanDate(std::string datestring)

Usage:

// the modification date in this example is "2023-January-23 08:30:00"

// will return false
bool dateBefore = AppsflyerLauncherModule()->IsInstallOlderThanDate("2023-January-01 23:12:34");

// will return true
bool dateAfter = AppsflyerLauncherModule()->IsInstallOlderThanDate("2023-April-10 23:12:34");

// example usage with skipFirst -
// skipping if the install date is NOT older than the given date
bool isInstallOlderThanDate = AppsflyerLauncherModule()->IsInstallOlderThanDate("2023-January-10 23:12:34");
AppsflyerLauncherModule()->Start(!isInstallOlderThanDate);

샘플 앱 실행

  1. Visual Studio를 설치합니다.
  2. 솔루션을 엽니다.
  3. AppsflyerSampleApp.cpp file.
  4. 112 라인에서 DEV_KEY and APP_ID앱 세부 정보로 교체합니다.
  5. 상단 도구 모음에서 재생 (로컬 Windows 디버거)을 클릭하여 앱을 실행합니다. 모드가 디버그로 설정되어 있는지 확인하십시오.
  6. 24시간 후 대시보드가 업데이트되고 오가닉 및 논오가닉 인스톨과 인앱이벤트가 표시됩니다.

앱스플라이어를 C++ 앱에 구현하기

Setup

  1. appsflyer-module 파일을 헤더 파일 > 앱스플라이어의 C++ 프로젝트로 복사합니다.
  2. 모듈을 가져옵니다.
#include "AppsflyerLauncherModule.h"
  1. 가져오기 nlohmann-json:
#include <nlohmann/json.hpp>
using json = nlohmann::json;
  1. 앱스플라이어 연동을 초기화하고 시작합니다.
  2. 인앱 이벤트를 리포트합니다.

Resetting the attribution

Remove the registry data from SOFTWARE\Microsoft\Windows\CurrentVersion\Run. The Registry keys are AF_counter_[APPID] and AF_uuid_[APPID].