Skip to content

Getting started with GDPR (display using WebView)🔗

GDPR integration requires a few simple steps:

Display Example

You can find examples of how the agreement looks in this format on the GDPR description page.

We also remind you that there is a second way of displaying the GDPR - Display and rendering of the interface by your means, with the results of actions reported to us.

Step 1. Import the GDPR module🔗

  • Add MRGSGDPR module

    Unity:

    Adding to the project (general instruction)

    Step 1. Add Sources

    To add MRGS to a project via the Unity Package Manager (available from Unity 2018+) simply add a scopedRegistries section to the Packages/manifest.json file by adding the following entry:

    {
        "dependencies": {
            ...
        },
        "scopedRegistries": [
                {
                    "name": "MRGS",
                    "url": "https://mrgs-nexus.my.games/repository/mrgs-uninty-plugins/",
                    "scopes": [
                        "games.my.mrgs"
                    ]
                }
        ]
    }
    

    Alternatively, you can click Edit -> Project Settings -> Package Manager -> '+' in scoped registry section, and fill in the fields according to the data above.

    Step 2. Add dependency

    • Click Window -> Package Manager -> select 'Packages: MyRegistries' from dropdown list, select package MRGSGDPR from the list, then click "Install"
    • Import the module: using MRGS;
    • Download the latest version of the library. Unzip the archive.
    • (For unitypackage integration) In Unity, click Assets -> Import Package -> Custom Package, and select the games.my.mrgs.gdpr.unitypackage package from the downloaded archive.
    • (For tgz integration) In Unity, click Window -> Package Manager -> '+' -> Add package from tarball, and select the games.my.mrgs.gdpr-<version> package. tgz from the downloaded archive.
    • Import the module: using MRGS;

    iOS:

    Adding to the project (general instruction)

    Step 1: Add dependencies

    Via Package collection

    • In Xcode select File > Add Packages
    • Select "+" > "Add Swift Package Collection"
    • Insert URL: https://mrgs-nexus.my.games/repository/ios-sdks/MRGSPackageCollection.json
    • Select module MRGSGDPR from "MRGS Package Collection".
    • Or you can select "MRGS" package from "MRGS Package Collection" (contains all mrgs modules as products) and then select "MRGS/GDPR" product only.

    Individual packages

    • In Xcode select File > Add Packages
    • In the search bar at the top right, paste the URL: https://mrgs-gitea.my.games/mrgs/mrgsgdpr-ios-sdk.git
    • Add a module to your project
    • Or you can paste the url https://mrgs-gitea.my.games/mrgs/ios-sdks.git to include the "MRGS" package which contains all mrgs modules as products and then select only the product" MRGS/GDPR".

    Step 2: Add support for ObjectiveC categories

    • Set the -ObjC flag in the "Other linker Flags" field in the project settings.
    • Import the module in code: @import MRGServiceKit; or @import MRGSGDPR; or #import <MRGSGDPR/MRGSGDPR.h>

    Step 1. Add Sources

    In your podfile, add sources to the top of the file:

    source 'https://github.com/CocoaPods/Specs.git' # For main repo
    source 'https://mrgs-gitea.my.games/mrgs/cocoapods-specs.git'  # For MRGS repo
    

    Step 2: Add dependencies

    Add the latest version of MRGSGDPR to target:

    To add via subspecs:

    target 'MyProject' do
        pod 'MRGS', '~> 5.0.0', :subspecs => ['GDPR']
    end
    

    To add via individual modules:

    target 'MyProject' do
        pod 'MRGSGDPR', '~> 5.0.0'
    end
    

    To add all mrgs modules:

    target 'MyProject' do
        pod 'MRGS/AllKits', '~> 5.0.0'
    end
    

    Step 3: Install dependencies

    • Run pod install (or pod install --repo-update if necessary)
    • Import the module in code: @import MRGServiceKit; or @import MRGSGDPR; or #import <MRGSGDPR/MRGSGDPR.h>

    Step 1: Add dependencies

    Add the dependency to your Cartfile:

    binary "https://mrgs-nexus.my.games/repository/ios-sdks/MRGSGDPR/MRGSGDPR.json" ~> 5.0.0
    

    Step 2: Install dependencies

    • Run carthage update --use-xcframeworks
    • Add downloaded frameworks to your project (make sure "do not embed" option is enabled)
    • Set the -ObjC flag in the "Other linker Flags" field in the project settings.
    • Import the module in code: @import MRGServiceKit; or @import MRGSGDPR; or #import <MRGSGDPR/MRGSGDPR.h>
    • Download the latest version of the library. Unzip the archive.
    • Add MRGSGDPR.xcframework from the downloaded archive to your project (Drag the libraries to the "Linked frameworks and Libraries" section) (Also contains MRGSGDPR.framework for compatibility - fat framework)

    • Add bundle with resources:

      • Add MRGSGDPRResources.bundle to the project by dragging it into the project structure.
      • Go to the "Copy Bundle Resources" section in the "Build Phases" tab, click "+", and select the desired bundle.
    • Set the -ObjC flag in the "Other linker Flags" field in the project settings.

    • Import the module in code: @import MRGSGDPR; or #import <MRGSGDPR/MRGSGDPR.h>
    • Also, you can add the MRGServiceKit.h and module.modulemap files from the archive to your project, or specify the path to them in the project settings in the Build Settings -> Header search paths section. Now, instead of importing each of our frameworks separately, you can only import one header file: @import MRGServiceKit;

    Android:

    Adding to the project

    Add a dependency in build.gradle file:

    dependencies {
        def mrgsVersion = "6.x.x"
    
        implementation "games.my.mrgs:gdpr:$mrgsVersion"
    }
    

    Copy the MRGSGDPR.aar file into the libs directory of your project. Add the necessary dependencies to the build.gradle file:

    dependencies {
        //...
        implementation(name: 'MRGSGDPR', ext:'aar')
    
        implementation 'androidx.appcompat:appcompat:1.6.1'
    }
    

Step 2. Set display options🔗

First of all, you need to set all the settings you need:

Delegate Before the display starts, it is necessary to set a delegate to receive the notification after choice is made by the user.
Ad permission If you want the agreement to also include the request to add personal data to the newsletter of advertisements and publisher news, set the corresponding flag withAdvertising (Set to False by default). For receiving ads and news will be shown another default file from the MRGS SDK
Display geolocation If you want to set the display only in the countries of the European Union, use the onlyEU flag (Set to YES by default, meaning shown only to Europeans).
Localization Agreement localization works only when working with HTML files. The choice of html localization is based on the currently selected language on the user's device. If You would like to provide your own localization you can do it with MRGSGDPRLocalization. If the language on the user's device is not supported and MRGSGDPRLocalization has not been passed, then localization in English ("en") will be used. If you use custom HTML-files and want them to be automatically localized, then you need to update them in accordance with our default samples (you can find them in the resources) by adding special tags instead of the agreement text that will be replaced by substitute text (otherwise your file will be displayed without changes). You can find tag names in our default agreement files. (To get the list of languages supported by us in ISO format, use the getSupportedLocalizations method)
Enabling COPPA For details, see COPPA page.

Parameter setting example:

// Initialize GDPR
MRGSGDPR.Instance.Setup("<PROJECT_ID>", "<PROJECT_SECRET>");

// Optional if you prefer listeners to callbacks.
MRGSGDPR.Instance.ShowDelegate = this;
// Default value: true
MRGSGDPR.Instance.OnlyEu = true;

// Extra params which you can use later to show agreement
MRGSGDPRShowParams showParams = new MRGSGDPRShowParams
{
    // Default value: false
    WithAdvertising = true,
    // Default value: Color.white
    BackgroundColor = Color.red,
    // Optional if you would like to use default localizations
    Localization = new MRGSGDPRLocalization("en")
    {
        Header = "Terms and Privacy",
        ContinueButton = "OK"
        // ...
        // Use more fields for localization
    }
};
MRGSGDPR.getInstance().Delegate = this;
MRGSGDPR.getInstance().withAdvertising(true); //Default false
MRGSGDPR.getInstance().SetBackgroundColor(255, 0, 0); // Default value is white color
MRGSGDPR.getInstance().onlyForEU(true);//Default true
MRGSGDPR.getInstance().setLocalizationLanguage("en"); //Default en (language identifier in ISO format)
// Initialize GDPR
[[MRGSGDPR sharedInstance] setupWithAppId:<PROJECT_ID> secret:@"<PROJECT_SECRET>"];

// Optional if you prefer listeners to callbacks.
[MRGSGDPR sharedInstance].showDelegate = self;
// Default value: true
[MRGSGDPR sharedInstance].onlyEU = true;

// Extra params which you can use later to show agreement
MRGSGDPRShowParams* showParams = [[MRGSGDPRShowParams alloc] init];
// Default value: false
showParams.withAdvertising = true;
// Default value: white
showParams.backgroundColor = [UIColor redColor];
// Optional if you would like to use default localizations
showParams.localization = [[MRGSGDPRLocalization alloc] initWithLanguage:@"fr"];

showParams.localization.header = @"Terms and Privacy";
showParams.localization.continueButton = @"OK";
// ...
// Use more fields for localization
MRGSGDPR* gdpr = [MRGSGDPR sharedInstance];
gdpr.delegate = self;
gdpr.withAdvertising = YES; //Default NO
gdpr.backgroundColorForWebView = [UIColor redColor]; //Default white color
gdpr.onlyEU = YES; //Default YES
gdpr.localizationLanguage = "en" //Default en (language identifier in ISO format)
import games.my.mrgs.gdpr.MRGSGDPR;
import games.my.mrgs.gdpr.MRGSGDPRLocalization;
import games.my.mrgs.gdpr.MRGSGDPRShowParams;

final MRGSGDPR gdpr = MRGSGDPR.getInstance();
// Initialize GDPR
gdpr.setup(Context, "<PROJECT_ID>", "<PROJECT_SECRET>");

// Optional if you prefer listeners to callbacks.
gdpr.setOnShowListener(this);
// Default value: true
gdpr.onlyEU(true);

// Extra params which you can use later to show agreement
final MRGSGDPRShowParams showParams = new MRGSGDPRShowParams();
// Default value: false
showParams.withAdvertising(true);
// Default value: white
showParams.setBackgroundColor(255, 0, 0);

// Optional if you would like to use default localizations
final MRGSGDPRLocalization localization = new MRGSGDPRLocalization.Builder()
        .setHeader("Terms and Privacy")
        .setContinueButton("OK")
        // ...
        // You can use other setters here.
        .build();
showParams.setLocalization(localization);
import games.my.mrgs.gdpr.MRGSGDPR;

final MRGSGDPR gdpr = MRGSGDPR.getInstance();
gdpr.setDelegate(this);
gdpr.onlyEU(true); //Default true
gdpr.setBackgroundColor(255, 0, 0); //Default white color
gdpr.withAdvertising(true); //Default false
gdpr.setLocalizationLanguage("en"); (language identifier in ISO format)
Background

If you want to set a different background color when loading HTML (usually needed for "heavy" files that take a long time to load), you can use backgroundColor/BackgroundColor (iOS/Unity) property, and setBackgroundColor (Android) method.

Agreement version

All projects have their own agreement version and it received from MRGS server. If you would like to show a new agreement version to users, you can change the version on MRGS console. You don't have to update MRGS SDK for it.

HTML localization

Localization with MRGSGDPRLocalization is available since MRGS 6.9.0 version. In previous version you could provide a language to change localization or you could try to change MRGS SDK localization files to your own.

Step 3. Display the agreement🔗

You can show our standard HTML with the agreement, or you can use your own custom HTML file stylized to fit the application interface.

Step 3.1 Standard HTML🔗

Use the method to show the agreement:

 // Show default agreement with default settings.
MRGSGDPR.Instance.ShowAgreement();

// Show default agreement with default settings and callback
MRGSGDPR.Instance.ShowAgreement(completion: (result, error) => {
    // Handle result here.
    // One of received params will be null.
});

// Show default agreement with extra settings to change behavior.
MRGSGDPR.Instance.ShowAgreement(param: showParams);

// Show default agreement with extra settings to change behavior and callback.
MRGSGDPR.Instance.ShowAgreement(param: showParams, (result, error) => {
    // Handle result here.
    // One of received params will be null.
});
 //Display standard agreement
MRGSGDPR.getInstance().showDefaultAgreement(APP_ID);

//Display your agreement from the HTML file
MRGSGDPR.getInstance().showAgreementFromFile(string appId, string filePath);
// Show default agreement with default settings.
[[MRGSGDPR sharedInstance] showAgreementAtViewController:self];

// Show default agreement with default settings and callback
[[MRGSGDPR sharedInstance] showAgreementAtViewController:self completionHandler:^(MRGSGDPRShowResult * _Nullable result, NSError * _Nullable error) {
    // Handle result here.
    // One of received params will be nil.
}];

// Show default agreement with extra settings to change behavior.
[[MRGSGDPR sharedInstance] showAgreementAtViewController:self params:showParams];

// Show default agreement with extra settings to change behavior and callback.
[[MRGSGDPR sharedInstance] showAgreementAtViewController:self 
                                                    params:showParams
                                        completionHandler:^(MRGSGDPRShowResult * _Nullable result, NSError * _Nullable error) {
    // Handle result here.
    // One of received params will be nil.
}];
MRGSGDPR* gdpr = [MRGSGDPR sharedInstance];
//Display standard agreement
[gdpr showDefaultAgreementAtViewController:self forAppId:APP_ID];

//Display your agreement from the HTML file
[gdpr showAgreementAtViewController:self forAppId:APP_ID fromFile:FILE_PATH];
import android.app.Activity;

import games.my.mrgs.gdpr.MRGSGDPR;
import games.my.mrgs.gdpr.MRGSGDPRLocalization;
import games.my.mrgs.gdpr.MRGSGDPRShowParams;

// Show default agreement with default settings.
MRGSGDPR.getInstance().showAgreement(Activity);

// Show default agreement with default settings and callback
MRGSGDPR.getInstance().showAgreement(Activity, (result, error) -> {
    // Handle result here.
    // One of received params will be null.
});

// Show default agreement with extra settings to change behavior.
MRGSGDPR.getInstance().showAgreement(Activity, showParams);

// Show default agreement with extra settings to change behavior and callback.
MRGSGDPR.getInstance().showAgreement(Activity, showParams, (result, error) -> {
    // Handle result here.
    // One of received params will be null.
});
import games.my.mrgs.gdpr.MRGSGDPR;

final MRGSGDPR gdpr = MRGSGDPR.getInstance();
//Display standard agreement
gdpr.showDefaultAgreementAtActivity(activity, APP_ID);

//Display your agreement from the HTML file
gdpr.showAgreementAtActivity(activity, APP_ID, filePath);

Step 3.2 Custom HTML🔗

Where should I put the custom HTML file?

For Unity:

The custom HTML file must be put into StreamingAssets or you can use native way which described bellow. Then pass the file name with extension (or the relative path from the above directories) into the method. For example, "myFile.html".

For iOS:

You can put the custom HTML file in any convenient place (usually in mainBundle), and transfer the full path to the file in NSURL format to the method.

For Android:

In assets, specify only its name with the extension (or the relative path from the above directories) in the method. For example, "myFile.html".

How to properly make a custom HTML file?

We recommend taking our standard agreement as a basis - it contains all the necessary elements (including elements for localization) and transitions. You can also download examples of our files from the link.

The most important thing to consider is the transition further when you press the button. When using a custom GDPR file, we understand that it is time to close the window and pull the callback of GET parameters by the presence of the checkboxAgree key in the query line after the button was pressed. Example: HTML/Path.html?checkboxAgree=on&checkboxContact=on. The easiest way to do this is by using a form - the standard mechanism allows you to add marked fields to GET. You can use our standard agreement file as a basis.

Please note that the accept button must be responsive (visually responsive to being clicked), otherwise the app may not be reviewed.

Also, we recommend you to check how the agreement looks in Korean, since in Korean you need to handle line breaks in a special way, we will automatically patch your custom file for the Korean language, but nevertheless, we advise you to check if everything looks as necessary.

// Will be shown if user has never accepted any agreements before
showParams.InitialAgreementFile = "your_agreement.html";
// Will be shown if user has accepted agreements and there's a new agreement version 
// on MRGS server
showParams.AgreementUpdateFile = "your_agreement_update.html";
// Will be shown if user has accepted agreements and publisher was changed. 
showParams.PublisherUpdateFile = "your_publisher_update.html";

// Show default agreement with extra settings to change behavior.
MRGSGDPR.Instance.ShowAgreement(param: showParams);

// Show default agreement with extra settings to change behavior and callback.
MRGSGDPR.Instance.ShowAgreement(param: showParams, (result, error) => {
    // Handle result here.
    // One of received params will be null.
});
// Show your own agreement file
MRGSGDPR.getInstance().showAgreementFromFile(string appId, string filePath);
NSURL* bundleUrl = [[NSBundle mainBundle] bundleURL];
// Will be shown if user has never accepted any agreements before
showParams.initialAgreementFilePath =  [bundleUrl URLByAppendingPathComponent:@"your_agreement.html"];
// Will be shown if user has accepted agreements and there's a new agreement version
// on MRGS server
showParams.agreementUpdateFilePath = [bundleUrl URLByAppendingPathComponent:@"your_agreement_update.html"];
// Will be shown if user has accepted agreements and publisher was changed.
showParams.publisherUpdateFilePath =  [bundleUrl URLByAppendingPathComponent:@"your_publisher_update.html"];

// Show default agreement with extra settings to change behavior.
[[MRGSGDPR sharedInstance] showAgreementAtViewController:self params:showParams];

// Show default agreement with extra settings to change behavior and callback.
[[MRGSGDPR sharedInstance] showAgreementAtViewController:self
                                                    params:showParams
                                        completionHandler:^(MRGSGDPRShowResult * _Nullable result, NSError * _Nullable error) {
    // Handle result here.
    // One of received params will be nil.
}];
// Show your own agreement file
NSURL* fileURL = [[NSBundle mainBundle] URLForResource:@"mrgsgdpr_custom" withExtension:@"html"];
[gdpr showAgreementAtViewController:<VC> forAppId:<APP_ID> fromFile:fileURL];
import android.app.Activity;

import games.my.mrgs.gdpr.MRGSGDPR;
import games.my.mrgs.gdpr.MRGSGDPRLocalization;
import games.my.mrgs.gdpr.MRGSGDPRShowParams;

// Will be shown if user has never accepted any agreements before
showParams.setInitialAgreementFile("your_agreement.html");
// Will be shown if user has accepted agreements and there's a new agreement version 
// on MRGS server
showParams.setUpdateAgreementFile("your_agreement_update.html");
// Will be shown if user has accepted agreements and publisher was changed. 
showParams.setPublisherUpdateFile("your_publisher_update.html");

// Show default agreement with extra settings to change behavior.
MRGSGDPR.getInstance().showAgreement(Activity, showParams);

// Show default agreement with extra settings to change behavior and callback.
MRGSGDPR.getInstance().showAgreement(Activity, showParams, (result, error) -> {
    // Handle result here.
    // One of received params will be null.
});
import games.my.mrgs.gdpr.MRGSGDPR;

// Show your own agreement file
gdpr.showAgreementAtActivity(activity, APP_ID, filePath);

Important

You need to call the display method at each start of the application. In case the user has already agreed with the GDPR, we will immediately call the delegate method.

Step 4. Handle the result🔗

The result of showing will be sent into listener As soon as the user presses the button:

// Optional implementation of IOnShowDelegate
// If you prefer listeners to callback
public void OnAgreementAccepted(MRGSGDPRShowResult result)
{
    // User accepted agreement
    // Handle result here.
}

public void OnAgreementError(MRGSError error)
{
    // User rejected agreement or there were an unknown issue
    // Handle result here.
}

// Or you can use callback instead of IOnShowDelegate
MRGSGDPR.Instance.ShowAgreement(completion: (result, error) => {
    // Handle result here.
    // One of received params will be null.
    if (error != null) 
    {
         // User rejected agreement or there were an unknown issue
    }
    if (result != null) 
    {
        // User accepted agreement
    }
});

// Or using await:
var res = await MRGSGDPR.Instance.ShowAgreementAsync();
// Implementation of IShowDelegate
// Successful completion
void OnUserHasAcceptedGDPR(bool withAdvertising) {

}

// User rejected the offer
void OnGDPRError() {

}
// Optional implementation of MRGSGDPRShowDelegate
// If you prefer listeners to callback
- (void)didAcceptAgreement:(MRGSGDPRShowResult*)result {
    // User accepted agreement
    // Handle result here.
}

- (void)didReceiveAgreementError:(NSError*)error {
    // User rejected agreement or there were an unknown issue
    // Handle result here.
}

// Or you can use callback instead of IOnShowDelegate
[[MRGSGDPR sharedInstance] showAgreementAtViewController:self completionHandler:^(MRGSGDPRShowResult * _Nullable result, NSError * _Nullable error) {
    // Handle result here.
    // One of received params will be nil.
    if (error != nil) {
        // User rejected agreement or there were an unknown issue
    }
    if (result != nil) {
        // User accepted agreement
    }
}];
//Successful completion
- (void)userHasAcceptedGDPR:(MRGSGDPR*)gdpr withAdvertising:(BOOL)value {

}

//User rejected the offer
- (void)errorShowingAgreement:(MRGSGDPR*)gdpr {

}
// Optional implementation of MRGSGDPR.OnShowListener
// If you prefer listeners to callback
@Override
public void onAgreementAccepted(@NonNull MRGSGDRPShowResult result) {
    // User accepted agreement
    // Handle result here.
}

@Override
public void onAgreementError(@NonNull MRGSError error) {
    // User rejected agreement or there were an unknown issue
    // Handle result here.
}

// Or you can use callback instead of MRGSGDPR.OnShowListener
MRGSGDPR.getInstance().showAgreement(..., (result, error) -> {
    // Handle result here.
    // One of received params will be null.
    if (error != null) {
         // User rejected agreement or there were an unknown issue
    }
    if (result != null) {
        // User accepted agreement
    }
});
//Successful completion
@Override
public void userHasAcceptedGDPR(boolean withAdvertising) {

}

//User rejected the offer
@Override
public void errorShowingAgreement() {

}

Note

If the user has already accepted the latest agreement, then the delegate method of the successful completion will be called immediately, meaning that you don't need to make any additional checks, we will do everything for you.

Get the latest accepted agreement🔗

To get the latest accepted agreement, use method:

var acceptedAgreement = MRGSGDPR.Instance.AcceptedAgreement;
if (acceptedAgreement == null)
{
    // User has never accepted any agreements yet.
}
var acceptedVersion = MRGSGDPR.getInstance().getAgreedVersion();
if (acceptedVersion == -1)
{
    // User has never accepted any agreements yet.
}
MRGSGDPRAcceptedAgreement* acceptedAgreement = [MRGSGDPR sharedInstance].acceptedAgreement;
if (acceptedAgreement == nil) {
    // User has never accepted any agreements yet.
}
int acceptedVersion = [[MRGSGDPR sharedInstance] getAgreedVersion];
if (acceptedVersion == -1) {
    // User has never accepted any agreements yet.
}
final MRGSGDPRAcceptedAgreement acceptedAgreement = MRGSGDPR.getInstance().getAcceptedAgreement(Context);
if (acceptedAgreement == null) {
    // User has never accepted any agreements yet.
}
final int acceptedVersion = MRGSGDPR.getInstance().getAcceptedAgreement(Context);
if (acceptedVersion == -1) {
    // User has never accepted any agreements yet.
}

Example🔗

void Awake () {
    MRGSGDPR.Instance.Setup("<PROJECT_ID>", "<PROJECT_SECRET>");

    // Optional if you prefer callbacks to listeners.
    // MRGSGDPR.Instance.ShowDelegate = this;
    MRGSGDPR.Instance.OnlyEu = true;

    MRGSGDPRShowParams showParams = new MRGSGDPRShowParams
    {
        WithAdvertising = true,
        BackgroundColor = Color.white,
        // Optional if you would like to use default localizations
        Localization = new MRGSGDPRLocalization("en")
        {
            Header = "Terms and Privacy",
            ContinueButton = "OK"
            // ...
            // Choose more field for localization
        }
    };

    MRGSGDPR.Instance.ShowAgreement(param: showParams, (result, error) => {
        // Handle result here.
        // One of received params will be null.
    });
}
void Awake () {
    MRGSGDPR.getInstance().Delegate = this;
    MRGSGDPR.getInstance().showDefaultAgreement(MRGS_APP_ID);
}

public void OnUserHasAcceptedGDPR(bool withAdvertising)
{
    // Start loading application/game
    // Initialize MRGS
    initMrgs();
}

public void OnGDPRError()
{
    // User declined the agreement. Close the application
    Application.Quit();
}
// Initialize GDPR
[[MRGSGDPR sharedInstance] setupWithAppId:<PROJECT_ID> secret:@"<PROJECT_SECRET>"];

// Optional if you prefer listeners to callbacks.
// [MRGSGDPR sharedInstance].showDelegate = self;
// Default value: true
[MRGSGDPR sharedInstance].onlyEU = true;

// Extra params which you can use later to show agreement
MRGSGDPRShowParams* showParams = [[MRGSGDPRShowParams alloc] init];
// Default value: false
showParams.withAdvertising = true;
// Default value: white
showParams.backgroundColor = [UIColor redColor];
// Optional if you would like to use default localizations
showParams.localization = [[MRGSGDPRLocalization alloc] initWithLanguage:@"fr"];

showParams.localization.header = @"Terms and Privacy";
showParams.localization.continueButton = @"OK";
// ...
// Use more fields for localization

[[MRGSGDPR sharedInstance] showAgreementAtViewController:self
                                                params:showParams
                                    completionHandler:^(MRGSGDPRShowResult * _Nullable result, NSError * _Nullable error) {
    // Handle result here.
    // One of received params will be nil.
}];
- (void)viewDidLoad {
    MRGSGDPR* gdpr = [MRGSGDPR sharedInstance];
    gdpr.delegate = self;
    UIViewController *rootController = [UIApplication sharedApplication].keyWindow.rootViewController;
    [gdpr showDefaultAgreementAtViewController:rootController forAppId:MRGS_APP_ID];
}

- (void)userHasAcceptedGDPR:(MRGSGDPR*)gdpr withAdvertising:(BOOL)flag {
    // Start loading application/game
    // Initialize MRGS
    [self initMRGS];
}

- (void)errorShowingAgreement:(MRGSGDPR*)gdpr {
    // User declined the agreement. Close the application
}
import android.app.Activity;

import androidx.annotation.NonNull;

import games.my.mrgs.MRGSError;
import games.my.mrgs.gdpr.MRGSGDPR;
import games.my.mrgs.gdpr.MRGSGDPRLocalization;
import games.my.mrgs.gdpr.MRGSGDPRShowParams;
import games.my.mrgs.gdpr.MRGSGDRPShowResult;

final MRGSGDPR gdpr = MRGSGDPR.getInstance();
gdpr.setup(Context, "<PROJECT_ID>", "<PROJECT_SECRET>");
// Optional if you prefer listeners to callbacks.
// gdpr.setOnShowListener(this);
gdpr.onlyEU(true);

final MRGSGDPRShowParams showParams = new MRGSGDPRShowParams();
showParams.withAdvertising(true);
showParams.setBackgroundColor(255, 0, 0);

// Optional if you would like to use default localizations
final MRGSGDPRLocalization localization = new MRGSGDPRLocalization.Builder()
        .setHeader("Terms and Privacy")
        .setContinueButton("OK")
        // ...
        // You can other setters here.
        .build();
showParams.setLocalization(localization);

// Show default agreement with extra settings to change behavior and callback.
MRGSGDPR.getInstance().showAgreement(Activity, showParams, (result, error) -> {
    // Handle result here.
    // One of received params will be null.
});
import games.my.mrgs.gdpr.MRGSGDPR;

public class MainActivity implements MRGSGDPR.MRGSGDPRDelegate {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        final MRGSGDPR gdpr = MRGSGDPR.getInstance();
        gdpr.setDelegate(this);
        gdpr.showDefaultAgreementAtActivity(this, MRGS_APP_ID);
    }

    @Override
    public void userHasAcceptedGDPR(boolean withAdvertising) {
        // Start loading application/game
        // Initialize MRGS
        initMRGS();
    }

    @Override
    public void errorShowingAgreement() {
        // User declined the agreement. Close the application
        finish();
    }
}

Last update: 2025-01-21
Created: 2020-02-17