{"id":21478240,"url":"https://github.com/appsflyersdk/appsflyer-epic-sample","last_synced_at":"2025-03-17T08:23:27.294Z","repository":{"id":154190430,"uuid":"616436866","full_name":"AppsFlyerSDK/appsflyer-epic-sample","owner":"AppsFlyerSDK","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-18T08:57:10.000Z","size":179,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-23T17:56:58.617Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AppsFlyerSDK.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-20T11:44:29.000Z","updated_at":"2024-07-18T08:57:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"64bb0d5e-7f24-45d1-a264-f3ce47f28a4c","html_url":"https://github.com/AppsFlyerSDK/appsflyer-epic-sample","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2Fappsflyer-epic-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2Fappsflyer-epic-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2Fappsflyer-epic-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2Fappsflyer-epic-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AppsFlyerSDK","download_url":"https://codeload.github.com/AppsFlyerSDK/appsflyer-epic-sample/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243997163,"owners_count":20380982,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-23T11:17:24.370Z","updated_at":"2025-03-17T08:23:27.258Z","avatar_url":"https://github.com/AppsFlyerSDK.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\ntitle: Epic C++\nparentDoc: 64ad642512c770006cfdd3fb\ncategory: 6446526dddf659006c7ea807\norder: 3\nhidden: false\nslug: epic-vanilla\n---\n\n\u003e Link to repository  \n\u003e [GitHub](https://github.com/AppsFlyerSDK/appsflyer-epic-sample)\n\n## AppsFlyer Epic C++ SDK integration\n\nAppsFlyer empowers gaming marketers to make better decisions by providing powerful tools that solve real pain points, including cross-platform attribution, mobile and web analytics, deep linking, fraud detection, privacy management and preservation, and more.\n\nGame attribution requires the game to communicate with AppsFlyer APIs over HTTPS and report user activities like first opens, consecutive sessions, and in-app events. For example, purchase events.\nWe recommend you use this sample app as a reference for integrating the code that reports user activities in your C++. \n\n**Note**: The sample code that follows is currently only supported in a Windows environment.\n\n### Prerequisites\n\n[vcpkg](https://vcpkg.io/en/index.html) openssl \u0026 nlohmann-json packages:\n\n```c++\nvcpkg install curl:x86-windows\nvcpkg install nlohmann-json:x86-windows\nvcpkg install openssl:x86-windows\n```\n\n\u003chr/\u003e\n\n## AppsflyerLauncherModule - Interface\n\n`AppsflyerLauncherModule.h`, included in the `appsflyer-module` folder, contains the required code and logic to connect to AppsFlyer servers and report events.\n\n### Init\n\nThis method receives your API key and app ID and initializes the AppsFlyer Module.\n\n**Method signature**\n\n```c++\nvoid Init(const char* devkey, const char* appID)\n```\n\n**Usage**:\n\n```c++\nAppsflyerLauncherModule()-\u003eInit(\u003c\u003c DEV_KEY \u003e\u003e, \u003c\u003c APP_ID \u003e\u003e);\n```\n\n\u003cspan id=\"app-details\"\u003e**Arguments**:\u003c/span\u003e\n\n- `EPIC_APP_ID`: Your Epic app id.\n- `DEV_KEY`: Get from the marketer or [AppsFlyer HQ](https://support.appsflyer.com/hc/en-us/articles/211719806-App-settings-#general-app-settings).\n\n### Start\n\nThis method sends first open/session requests to AppsFlyer.\n\n**Method signature**\n\n```c++\nvoid Start(bool skipFirst = false)\n```\n\n**Arguments**\n\n- `bool skipFirst`: Determines whether or not to skip first open events and send session events. The value is false by default. If true , first open events are skipped and session events are sent. [See example](#skipFirstExample)\n\n**Usage**:\n\n```c++\n// without the flag\nAppsflyerLauncherModule()-\u003eStart();\n\n// with the flag\nbool skipFirst = [SOME_CONDITION];\nAppsflyerLauncherModule()-\u003eStart(skipFirst);\n```\n\n### Stop\n\nThis method stops the SDK from functioning and communicating with AppsFlyer servers. It's used when implementing user opt-in/opt-out.\n\n**Method signature**\n\n```c++\nvoid Stop()\n```\n\n**Usage**:\n\n```c++\n// Starting the SDK\nAppsflyerLauncherModule()-\u003eStart();\n// ...\n// Stopping the SDK, preventing further communication with AppsFlyer\nAppsflyerLauncherModule()-\u003eStop();\n```\n\n### LogEvent\n\nThis method receives an event name and JSON object and sends in-app events to AppsFlyer.\n\n**Method signature**\n\n```c++\nvoid LogEvent(std::string event_name, json event_values, json custom_event_values = {})\n```\n\n**Arguments**\n\n- `std::string event_name`-\n- `json event_parameters`: dictionary object which contains the [predefined event parameters](https://dev.appsflyer.com/hc/docs/ctv-log-event-event-parameters).\n- `json event_custom_parameters` (non-mandatory): dictionary object which contains the any custom event parameters. For non-English values, please use [UTF-8 encoding](#to_utf8).\n\n**Usage**:\n\n```c++\n// Setting the event values json and event name\nstd::string event_name = \"af_purchase\";\njson event_parameters = { {\"af_currency\", \"USD\"}, {\"af_revenue\", 24.12} };\n// Send LogEvent request\nAppsflyerLauncherModule()-\u003eLogEvent(event_name, event_parameters);\n\n// Send LogEvent request with custom event params and UTF8 encoding (for non-English characters)\nstd::wstring ws = L\"車B1234 こんにちは\";\nstd::wstring ws2 = L\"新人邀约购物日\";\njson custom_event_parameters = { \n    {\"goodsName\", AppsflyerLauncherModule()-\u003eto_utf8(ws)}, \n    {\"goodsName2\", AppsflyerLauncherModule()-\u003eto_utf8(ws2)} \n};\nAppsflyerLauncherModule()-\u003eLogEvent(event_name, event_parameters, custom_event_parameters);\n```\n\n**Note**: To use the JSON, make sure to use the following imports:\n\n```c++\n#include \u003cnlohmann/json.hpp\u003e\nusing json = nlohmann::json;\n```\n\n### SetCustomerUserId\n\nThis method sets a customer ID that enables you to cross-reference your unique ID with the AppsFlyer unique ID and other device IDs. Note: You can only use this method before calling `Start()`.\nThe customer ID is available in raw data reports and in the postbacks sent via API.\n\n**Method signature**\n\n```c++\nvoid SetCustomerUserId(std::string cuid)\n```\n\n**Arguments**:\n\n- `std::string cuid`: Custom user id.\n\n**Usage**:\n\n```c++\nAppsflyerLauncherModule()-\u003eInit(DEV_KEY, APP_ID);\nAppsflyerLauncherModule()-\u003eSetCustomerUserId(\"Test-18-9-23\");\nAppsflyerLauncherModule()-\u003eStart();\n```\n\n### SetSharingFilterForPartners\n\nThis method lets you configure which partners should the SDK exclude from data-sharing. Partners that are excluded with this method will not receive data through postbacks, APIs, raw data reports, or any other means.\n\n**Method signature**\n\n```c++\nvoid SetSharingFilterForPartners(std::string sharingFilter)\n```\n\n**Arguments**:\n\n- `std::string sharingFilter`: a list of partners to filter. For example:  `std::string list = \"[\\\"partner1\\\",\\\"partner2\\\"]\"`. \nPlease use `[\\\"all\\\"]` in order to not send the event to any source.\n\n**Usage**:\n\n```c++\nAppsflyerLauncherModule()-\u003eInit(DEV_KEY, APP_ID);\n\n// set the sharing filter for partners a, b \u0026 c. please use [\"all\"] in order to not send the event to any source.\nAppsflyerLauncherModule()-\u003eSetCustomerUserId(\"[\\\"a\\\",\\\"b\\\",\\\"c\\\"]\");\n\n// start the SDK (send firstopen/session request)\nAppsflyerLauncherModule()-\u003eStart();\n```\n\n### OnCallbackSuccess, OnCallbackFailure\n\nThe above methods are placeholders for the desired actions upon success/failure.  \nIt is possible to handle different types of events with the switch case of the context within each function (“FIRST_OPEN_REQUEST”, ”SESSION_REQUEST”, ”INAPP_EVENT_REQUEST”).\n\n**Method signature**\n\n```c++\nvoid OnCallbackSuccess(long responseCode, uint64 context)\nvoid OnCallbackFailure(long responseCode, uint64 context)\n```\n\n### GetAppsFlyerUID\n\nGet AppsFlyer's unique device ID. The SDK generates an AppsFlyer unique device ID upon app installation. When the SDK is started, this ID is recorded as the ID of the first app install.\n\n**Method signature**\n\n```c++\nstd::string GetAppsFlyerUID()\n```\n\n**Usage**:\n\n```c++\nAppsflyerLauncherModule()-\u003eGetAppsFlyerUID();\n```\n\n### To_utf8\n\nThis method receives a reference of a `std::wstring` and returns UTF-8 encoded `std::string`\n\n**Method signature**\n\n```c++\nstd::string to_utf8(std::wstring\u0026 wide_string);\n```\n\n**Usage**:\n\n```c++\nstd::wstring ws = L\"車B1234 こんにちは\";\nstd::wstring ws2 = L\"新人邀约购物日\";\ncustom_event_parameters = { \n    {\"goodsName\", AppsflyerLauncherModule()-\u003eto_utf8(ws)}, \n    {\"goodsName2\", AppsflyerLauncherModule()-\u003eto_utf8(ws2)} \n};\n```\n\n### IsInstallOlderThanDate\n\nThis 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\"\n\n**Method signature**\n\n```c++\nbool IsInstallOlderThanDate(std::string datestring)\n```\n\n**Arguments**:\n\n- `std::string datestring`: Date string in `yyyy-mm-ddThh:mm:ss+hh:mm` format.\n\n**Usage**:\n\u003cdiv id=\"skipFirstExample\"\u003e\u003c/div\u003e\n\n```c++\n// the modification date in this example is \"2023-January-23 08:30:00\"\n\n// will return false\nbool dateBefore = AppsflyerLauncherModule()-\u003eIsInstallOlderThanDate(\"2023-January-01 23:12:34\");\n\n// will return true\nbool dateAfter = AppsflyerLauncherModule()-\u003eIsInstallOlderThanDate(\"2023-April-10 23:12:34\");\n\n// example usage with skipFirst -\n// skipping if the install date is NOT older than the given date\nbool isInstallOlderThanDate = AppsflyerLauncherModule()-\u003eIsInstallOlderThanDate(\"2023-January-10 23:12:34\");\nAppsflyerLauncherModule()-\u003eStart(!isInstallOlderThanDate);\n```\n\n## Running the sample app\n\n1. Install [Visual Studio](https://visualstudio.microsoft.com/).\n2. Open the solution.\n3. Open the `AppsflyerSampleApp.cpp` file.\n4. On line 112, replace `DEV_KEY` and `APP_ID` with your [app details](#app-details).\n5. Run the app by clicking **Play** on the top toolbar (Local Windows Debugger). Make sure that the mode is set to Debug.\n6. After 24 hours, the dashboard updates and shows organic and non-organic installs and in-app events.\n\n## Implementing AppsFlyer in your C++ app\n\n### Setup\n\n1. Copy the files from the `appsflyer-module` folder into your C++ project under **Header Files** \u003e **AppsFlyer**.\n2. Import the Module:\n\n```c++\n#include \"AppsflyerLauncherModule.h\"\n```\n\n3. Import `nlohmann-json`:\n\n```c++\n#include \u003cnlohmann/json.hpp\u003e\nusing json = nlohmann::json;\n```\n\n4. [Initialize](#init) and [start](#start) the AppsFlyer integration.\n5. Report [in-app events](#logevent).\n\n## Resetting the attribution\n\nRemove the registry data from `SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run`. The Registry keys are `AF_counter_[APPID]` and `AF_uuid_[APPID]`.\n\n\n## Deleting AppsFlyer data on uninstall\n\nWhen uninstalling your app, please make sure to remove the registry data from `SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run`. The Registry keys are `AF_counter_[APPID]` and `AF_uuid_[APPID]`.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappsflyersdk%2Fappsflyer-epic-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappsflyersdk%2Fappsflyer-epic-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappsflyersdk%2Fappsflyer-epic-sample/lists"}