Skip to content

Unreal Engine SDK connection🔗

Minimum requirements🔗

Minimum supported version is Unreal Engine 4.26, Android 4.4(API: 19), and 13.0 for iOS. Also, the MRGS base module supports all platforms based on Unity, such as PlayStation, Switch, XBOX, OSX, etc.

Integration🔗

To integrate the MRGS library you need to complete four simple steps:

Step 1. Add the library to the project🔗

  • Download the latest version of the library.
  • Unzip the archive.
  • Copy MRGService plugin into your project {project}/Plugins/

Huawei/AppTouch Store

To support the Huawei/AppTouch Store, add:
1) com.huawei.hms:ads-identifier:3.4.62.300 according to documentation.
2) com.huawei.hms:opendevice:6.11.0.300 according to documentation.

Step 2. Call the initialization method🔗

Call the initialization method MRGService.Instance.Initialize(). The arguments must be specified MRGS_APP_ID, CLIENT_SECRET.

#include "MRGService.h"

void AppGameMode::BeginPlay()
{

    if (!FMRGService::Get().IsInitialized())
    {
        FMRGServiceParams ServiceParams;
        ServiceParams.AppId = TEXT("<MRGS_APP_ID>");
        ServiceParams.AppSecret = TEXT("<CLIENT_SECRET>");
        FMRGService::Get().Initialize(ServiceParams);
    }
}

Android FMRGSPlatform

When initializing MRGService under Android, you need to pass FMRGSPlatform (that is, the store where you plan to upload the build).

MRGS_APP_ID and CLIENT_SECRET

MRGS_APP_ID - Application ID on the MRGS website. CLIENT_SECRET - Client Key. You can get them from the MRGS website, in the settings section of your application Important! Do not forget that these parameters are different for Android and iOS builds. Use the correct initialization keys app_settings

Attention! Calling any methods (except the GDPR) before calling the SDK start method can lead to undefined MRGS behavior. Be careful not to start working with MRGS before calling the initialization method!

User tracking request on iOS 14+

In case you want to show a popup of a request for tracking permissions (getting IDFA) in iOS 14, you can use our display methods. Usually IDFA is required for ad tracking, you can read more on the link above

Step 3 (Optional). Add account login tracking🔗

If your application uses a player identifier (USER_ID), it must be passed to MRGS using the method:

#include "MRGSUsers.h"

FMRGSUsers::Get().SetUserId("<USER_ID>");

Step 4. Add payment tracking🔗

After the payment is made, it is necessary to report data about it to MRGS.

iOS

By default, MRGS on iOS will automatically collect all payment data using autotracking, no further action is required.

If you don't want to use autotracking, then you need to turn off automatic payment tracking (serviceParams.IOSExtraOptions.AutomaticPaymentTracking = false;) and use the method for direct transfer of payment data described below (not recommended approach).

To send payment data, you can use the following method:

#include "MRGSMetrics.h"

FMRGSMetrics::Get().AddPurchase;

Examples of sending payment data on different platforms:

Example for Android (GooglePlay)

skuDetails - product information in JSON format. You can get it by calling the getSkuDetails method.
purchaseData - this is the INAPP_PURCHASE_DATA field received from Google reply after purchase getBuyIntent method.
dataSignature - this is the INAPP_PURCHASE_SIGNATURE field received from Google reply after purchase getBuyIntent method.

#include "MRGSMetrics.h"

FMRGSMetrics::Get().AddPurchaseGoogle("<skuDetails>", "<purchaseData>", "<dataSignature>");
Example for Huawei/AppTouch

inAppPurchaseDataJson - purchase information in JSON format. You can get it by calling the com.huawei.hms.iap.entity.PurchaseResultInfo#getInAppPurchaseData() method.
inAppSignature - encrypted payment information. You can get it by calling the com.huawei.hms.iap.entity.PurchaseResultInfo#getInAppDataSignature() method.

#include "MRGSMetrics.h"

FMRGSMetrics::Get().AddPurchaseHuawei("<inAppPurchaseDataJson>", "<inAppSignature>");
Example for Samsung

productVoJson - product information in JSON format. You can get it by calling the com.samsung.android.sdk.iap.lib.vo.ProductVo#getJsonString() method.
purchaseVoJson - purchase information in JSON format. You can get it by calling the com.samsung.android.sdk.iap.lib.vo.PurchaseVo#getJsonString() method.

#include "MRGSMetrics.h"

FMRGSMetrics::Get().AddPurchaseSamsung("<productVoJson>", "<purchaseVoJson>");
Example for Amazon

productJson - product information in JSON format. You can get it by calling the com.amazon.device.iap.model.Product#toJSON() method.
receiptJson - purchase information in JSON format. You can get it by calling the com.amazon.device.iap.model.Receipt#toJSON() method.
userDataJson - buyer information in JSON format. You can get it by calling the com.amazon.device.iap.model.UserData#toJSON() method.

#include "MRGSMetrics.h"

FMRGSMetrics::Get().AddPurchaseAmazon("<productJson>", "<receiptJson>", "<userDataJson>");
Example for iOS

Ev - product information.
transactionReceipt - transaction receipt in old base64 format (not applicationReceipt).

#include "MRGSMetrics.h"

// Setting SDK params
FMRGExtraOptionsIOS.bIsAutomaticPaymentTrackingEnabled = false

// Sending payment
FMRGSPurchaseEvent Ev;
Ev.OrderId = TEXT("1000000353116913");
Ev.ProductId = TEXT("games.my.mrgs.weapon6");
Ev.LocalizedTitle = TEXT("Great gold weapon");
Ev.LocalizedDescription = TEXT("Destroy anyone with this gun. Limited edition!");
Ev.Price = 15;
Ev.PriceCurrency = TEXT("USD");

FString TransactionReceipt(TEXT("MIIVSwYJKoZIhvcNAQcCoIIVPDCCFTgCAQExCzAJBgUrDg.........85+V19vrPYvnHcHh8yZEpRhtmlRmlWN+AWhJmYjuu4SGfIzg3oo416EWIYV8tke3t8pmHGClmoO7q+478RDbnmuBROz/1NQdlevyeyFkae/VCDRQ=="));

FMRGSMetrics::Get().AddPurchaseApple(En, TransactionReceipt);
Example for Standalone platform (Windows, OSX, PlayStation, Xbox, Switch, etc.)
#include "MRGSMetrics.h"

FMRGSPurchaseEvent Ev;
Ev.OrderId = TEXT("123456789");
Ev.ProductId = TEXT("games.my.mrgs.weapon6");
Ev.LocalizedTitle = TEXT("Great gold weapon");
Ev.LocalizedDescription = TEXT("Limited edition");
Ev.Price = 1234.5;
Ev.PriceCurrency = TEXT("USD");

FMRGSMetrics::Get().AddPurchase(En);

Important

  • Payment tracking is necessary if you do not use the MRGSBank module.
  • Make sure that on the site https://mrgs.astrum.team, in the settings of your application, the fields with keys for validating payments are filled in and the setting "Only validation of payments (without processing)" is enabled.
  • MRGS will automatically send information about purchases to all the configured SDKs: AppsFlyer(only iOS, Android, Huawei/AppTouch and Samsung purchases), Firebase(only iOS and Android purchases), MyTracker(only iOS and Android purchases) if the corresponding modules are enabled
  • Autotracking on iOS is automatically disabled when using the MRGSBank module.

Integration check🔗

After completing the MRGS integration, we recommend that you verify that the library is working correctly. To learn how to perform this procedure, see Integration checks and troubleshooting section.


Last update: 2025-01-21
Created: 2023-04-04