Requirements🔗
Requires to update some libraries which supported TCF, and integrate TCF module.
- Update MRGService(core) to
6.10.0or higher. - Update IronSource to
7.7.0or higher. - If ISMRGSCustomAdapter is used , update it to
6.10.0or higher. - Integrate module MRGSDidomi TCF module.
Add module to project🔗
Add to Unity 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 packageMRGSDidomifrom 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 thegames.my.mrgs.didomi.unitypackagepackage from the downloaded archive. - (For tgz integration) In Unity, click
Window -> Package Manager -> '+' -> Add package from tarball, and select thegames.my.mrgs.didomi-<version> package. tgzfrom the downloaded archive. - Import the module:
using MRGS;
Add to iOS 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 MRGSDidomi from "MRGS Package Collection".
- Or you can select "MRGS" package from "MRGS Package Collection" (contains all mrgs modules as products) and then select "MRGS/Didomi" 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/mrgsdidomi-ios-sdk.git - Add a module to your project
- Or you can paste the url
https://mrgs-gitea.my.games/mrgs/ios-sdks.gitto include the "MRGS" package which contains all mrgs modules as products and then select only the product" MRGS/Didomi".
Step 2: Add support for ObjectiveC categories
- Set the
-ObjCflag in the "Other linker Flags" field in the project settings. - Import the module in code:
@import MRGServiceKit;or@import MRGSDidomi;or#import <MRGSDidomi/MRGSDidomi.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 MRGSDidomi to target:
To add via subspecs:
To add via individual modules:
To add all mrgs modules:
Step 3: Install dependencies
- Run
pod install(orpod install --repo-updateif necessary) - Import the module in code:
@import MRGServiceKit;or@import MRGSDidomi;or#import <MRGSDidomi/MRGSDidomi.h>
Step 1: Add dependencies
Add the dependency to your Cartfile:
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
-ObjCflag in the "Other linker Flags" field in the project settings. - Import the module in code:
@import MRGServiceKit;or@import MRGSDidomi;or#import <MRGSDidomi/MRGSDidomi.h>
- Download the latest version of the library. Unzip the archive.
-
Add
MRGSDidomi.xcframeworkfrom the downloaded archive to your project (Drag the libraries to the "Linked frameworks and Libraries" section) (Also contains MRGSDidomi.framework for compatibility - fat framework) -
Set the
-ObjCflag in the "Other linker Flags" field in the project settings. - Import the module in code:
@import MRGSDidomi;or#import <MRGSDidomi/MRGSDidomi.h> - Also, you can add the
MRGServiceKit.handmodule.modulemapfiles from the archive to your project, or specify the path to them in the project settings in theBuild Settings -> Header search pathssection. Now, instead of importing each of our frameworks separately, you can only import one header file:@import MRGServiceKit;
Add to Android project
Add a dependency in build.gradle file:
SDK Initialization🔗
Before initializing SDK, you need to get the AppKey and NoticeId.
- AppKey - one common to MY.GAMES. You can find it in Didomi console on main page
- NoticeId - each project has their own
NoticeId. You can find it in Didomi console on Consent Notices

Then initialize MRGSDidomi SDK:
GDPR
If your project supports GDPR, you should initialize Didomi after GDPR when user accepted GDPR agreements.
Logic of initializing advertising SDK🔗
Important: Initialization of any advertising SDKs should be postponed until the moment of receiving consent.
You should implement a logic of enabling advertising SDKs based on TCF result and mapping purposes and ID from Didomi. Important to support next possible cases:
- Case 1: You received full consent from the user ((opt-in): all consent/legitimate interest enabled). You can enable all advertising SDKs, and show personalized ad.
- Case 2: You received a complete rejection from the user ((opt-out) => all consent/legitimate interest disabled). You MUSTN'T initialize any advertising SDKs, you MUSTN'T show any ads to user.
- Case 3: Partial agreement, but user rejected Purpose 1 (consent disabled
cookies). You MUSTN'T initialize any advertising SDKs, you MUSTN'T show any ads to user. - Case 4: Partial agreement, user accepted Purpose 1, but rejected Purpose 3 and 4 (consent enabled
cookies+ consent disabledcreate_ads_profile;select_personalized_ads). You CAN enable advertising SDK's, but you CAN show not personalized ads only.
If you have received consent for Purpose 1, you can initialize advertising SDK's, including IronSource SDK mediation. It is also necessary to send the results of consent/disagreement to mediation for Purpose 3 and 4 (personalized advertising).
IronSource
According to documentation, you can send the consent/disagreement results to Purpose 3 and 4 as follows:
Tapjoy Offerwall
That SDK can be initialized only when you received consent for Purpose 1, because this SDK collects personal data.
According to documentation, Tapjoy has his own flags:
If user agreed with Purpose 1, but disagreed with Purpose 3 and 4 - TJStatusFalse
If user agreed with Purpose 1, 3, and 4 - TJStatusTrue
Showing TCF window🔗
Logic of showing TCF window🔗
If you haven't received consent, you can't show any ads, including cross-promo. If for some reason Didomi SDK was not initialized or initialized with an error and the TCF window was not shown, it is considered that consent was not received and the window needs to be called again.
For projects without Interstitial🔗
With user-initiated format; If you haven't received TCF consent at the start of the game, you should show TCF banner instead ad when user is trying to watch video by clicking ad button.
For projects with Interstitial🔗
If you haven't received TCF consent at the start of the game, you should show TCF banner at the moment of logging into the game, when the user should see the first interstitial, for example:
- If planning to show interstitial in the first session, show TCF immediately after showing ToS/Privacy Policy and ATT.
- If planing to show interstitial on the 7th day, TCF is shown at the start of the game for players whose day of life is >= 7, while if the user wanted to watch Rewarded Video before interstitial, you should show TCF when user clicked on the “Show ads” button.`
Showing main banner (1st layer)🔗
Notice
You don't have to wait for the Ready event before calling showNotice, because it will be called internally (by Didomi SDK itself). Therefore, when calling this method, the consent banner or preference will be displayed only if it is required (if user is under TCF), and only after SDK is ready.
Showing preferences (2nd layer)🔗
You should add a Privacy Settings button in settings. TCF will show preferences window(2nd layer with purposes). It is better to have an identical name on button for everyone, since we refer to this button in the general privacy policy.
To show preferences (2nd layer):
Important
You don't have to wait for the Ready event before calling showPreferences, because it will be called internally (by Didomi SDK itself).
Additional features🔗
Specific knowledge🔗
It is very important to take into account that when you working with the Didomi SDK API, you should call it only after successful initialization of SDK. Otherwise, it can lead to: crashes, incorrect return of results, or API simply will not respond to requests. There is only exception for initialization and setting delegates/listeners API, the last one should be called before calling the initialization API.
The result of successful initialization of SDK is an onReady event from the delegate/listener.
Main delegate/listener🔗
DidomiEventListener is a main delegate/listener in Didomi, provides a lot events. Only important events were implemented in MRGSDidomi for Unity, but will be able to add the rest of the required/necessary events upon request.
To set up/remove delegate/listener:
var listener = new MRGSDidomiEventListener();
listener.Ready += (o, e) => {
Debug.Log("Didomi#OnReady was called.");
};
listener.Error += (o, e) => {
Debug.Log("Didomi#OnError was called: " + e.ErrorMessage);
};
listener.ShowNotice += (o, e) => {
Debug.Log("Didomi#OnShowNotice was called.");
};
listener.HideNotice += (o, e) => {
Debug.Log("Didomi#OnHideNotice was called.");
};
listener.ShowPreferences += (o, e) => {
Debug.Log("Didomi#OnShowPreferences was called.");
};
listener.HidePreferences += (o, e) => {
Debug.Log("Didomi#OnHidePreferences was called.");
};
listener.ConsentChanged += (o, e) => {
Debug.Log("Didomi#ConsentChanged was called.");
};
MRGSDidomi.Instance.AddEventListener(listener);
MRGSDidomi.Instance.Setup(MRGSDidomiInitializeParameters);
// MRGSDidomi.Instance.RemoveEventListener(listener);
DDMEventListener* listener = [[DDMEventListener alloc] init];
listener.onReady = ^(enum DDMEventType type) {
};
listener.onConsentChanged = ^(enum DDMEventType type) {
};
listener.onShowPreferences = ^(enum DDMEventType type) {
};
[[MRGSDidomi sharedInstance] addEventListener:listener];
// Init Didomi SDK
// [[MRGSDidomi sharedInstance] removeEventListener:listener];
import android.util.Log;
import androidx.annotation.NonNull;
import games.my.mrgs.didomi.MRGSDidomi;
import io.didomi.sdk.DidomiInitializeParameters;
import io.didomi.sdk.events.ConsentChangedEvent;
import io.didomi.sdk.events.ErrorEvent;
import io.didomi.sdk.events.EventListener;
import io.didomi.sdk.events.HideNoticeEvent;
import io.didomi.sdk.events.HidePreferencesEvent;
import io.didomi.sdk.events.ReadyEvent;
import io.didomi.sdk.events.ShowNoticeEvent;
import io.didomi.sdk.events.ShowPreferencesEvent;
import io.didomi.sdk.functionalinterfaces.DidomiEventListener;
final DidomiEventListener listener = new EventListener() {
@Override
public void ready(@NonNull ReadyEvent event) {
Log.d("Didomi", "#OnReady was called.");
}
@Override
public void error(@NonNull ErrorEvent event) {
Log.d("Didomi", "#OnError was called: " + event.getErrorMessage());
}
@Override
public void showNotice(@NonNull ShowNoticeEvent event) {
Log.d("Didomi", "#OnShowNotice was called.");
}
@Override
public void hideNotice(@NonNull HideNoticeEvent event) {
Log.d("Didomi", "#OnHideNotice was called.");
}
@Override
public void showPreferences(@NonNull ShowPreferencesEvent event) {
Log.d("Didomi", "#OnShowPreferences was called.");
}
@Override
public void hidePreferences(@NonNull HidePreferencesEvent event) {
Log.d("Didomi", "#OnHidePreferences was called.");
}
@Override
public void consentChanged(@NonNull ConsentChangedEvent event) {
Log.d("Didomi", "#ConsentChanged was called.");
}
};
MRGSDidomi.getInstance().addEventListener(listener);
MRGSDidomi.getInstance().setup(Context, DidomiInitializeParameters);
// MRGSDidomi.getInstance().removeEventListener(listener);
Events meaning
DidomiEventListener#Ready - Didomi SDK has been successfully initialized and you can work with other SDK API. DidomiEventListener#Error - There was a error during Didomi SDK initialization (method can also be called while the SDK is running). If the error persists, there may be problems with the AppKey or NoticeId. If you try to call other SDK API, you may get undefined behaviors. DidomiEventListener#ShowNotice - User is observing the main agreement banner (1st layer).
DidomiEventListener#HideNotice - User has closed the main agreement banner (1st layer).
DidomiEventListener#ShowPreferences - User is observing the preferences window (2nd layer). This event can also be triggered every time when user opens this window from the 1st layer.
DidomiEventListener#HidePreferences - User has closed the preferences window (2st layer). This event can also be triggered every time when user opened this window from the 1st layer.
DidomiEventListener#ConsentChanged - Calls every time user has made the first decision in the main banner (1st layer) or changes his decisions later through the preferences (2nd layer).
Extra delegate/listener🔗
MRGSDidomi SDK offers an extra MRGSDidomiListener delegate/listener to simplify some logic/functionality. The number of events may change in the future.
To set up/remove delegate/listener:
class YourClass : MRGSDidomi.IDelegate
{
YourClass()
{
MRGSDidomi.Instance.Delegate = this;
MRGSDidomi.Instance.Setup(MRGSDidomiInitializeParameters);
// MRGSDidomi.Instance.Delegate = null;
}
public void OnReceiveConsentStatus()
{
Debug.Log("Didomi#OnReceiveConsentStatus was called.");
// Write here extra logic base on user's choice to initialize ads SDK's
}
}
@interface DidomiDelegateListener: NSObject <MRGSDidomiDelegate>
@end
@implementation DidomiDelegateListener
-(void)setup{
[MRGSDidomi sharedInstance].delegate = self;
// [MRGSDidomi sharedInstance].delegate = nil;
}
- (void)didReceiveConsentStatus {
NSLog(@"Didomi#OnReceiveConsentStatus was called.");
// Write here extra logic base on user's choice to initialize ads SDK's
}
@end
import android.util.Log;
import games.my.mrgs.didomi.MRGSDidomi;
import games.my.mrgs.didomi.MRGSDidomiListener;
import io.didomi.sdk.DidomiInitializeParameters;
final MRGSDidomiListener listener = new MRGSDidomiListener() {
@Override
public void onReceiveConsentStatus() {
Log.d("MRGSDidomi", "#onReceiveConsentStatus was called.");
// Write here extra logic base on user's choice to initialize ads SDK's
}
};
MRGSDidomi.getInstance().setOnDidomiListener(listener);
MRGSDidomi.getInstance().setup(context, config);
// MRGSDidomi.getInstance().setOnDidomiListener(null);
Events meaning
Will be called only once per session and signals that the project can start initializing advertising SDK's. This event hides such checks as: Successful initialization of the Didomi SDK, whether the user is under TCF, whether user agreed with TCF before or has just agreed now. Please note this event only signals about perfect moment to initialize advertising SDK's, but the project still needs to write additional logic based on the result of the user's action: whether he allowed to show him ads and whether he allowed to show him personalized ads.
Check for showing consent requirements🔗
To check whether you can show TCF agreement to users:
Important
This method will always return false if Didomi SDK is not initialized or is not ready to work.
Check the permission to show ads🔗
To check whether user has allowed to show him ads (Purpose 1 - cookies), use the method:
Important
This method will always return an undefined result if the Didomi SDK is not initialized or is not ready to work.
Check the permission to show personalized ads🔗
To check whether the user has allowed to show him personalized ads (Purpose 3 and 4 - create_ads_profile and select_personalized_ads), use the method:
Important
This method will always return an undefined result if the Didomi SDK is not initialized or is not ready to work.
Check whether the user has accepted the agreement🔗
To check whether the user has previously accepted the agreement, use the method:
Important
This method will always return false if Didomi SDK is not initialized or is not ready to work.
Get Consent String🔗
To get Consent String use the method:
Checking the status of purposes🔗
To get a list of purposes, map and check their statuses:
var userStatus = MRGSDidomi.Instance.UserStatus;
if (userStatus == null) {
// Didomi wasn't initialized or ready
return;
}
var purposes = userStatus.Purposes;
// You can also check Consent and Legitimate Interest statuses.
var consent = purposes.Consent;
var isCookiesEnabled = consent.Enabled.Contains("cookies");
var isCookiesDisabled = consent.Disabled.Contains("cookies");
// etc
DDMUserStatus* userStatus = [MRGSDidomi sharedInstance].userStatus;
if(userStatus == nil){
// Didomi wasn't initialized or ready
return;
}
DDMUserStatusPurposes* purposes = userStatus.purposes;
// You can also check Consent and Legitimate Interest statuses.
DDMUserStatusIDs* consent = purposes.consent;
BOOL isCookiesEnabled = [consent.enabled containsObject:@"cookies"];
BOOL isCookiesDisabled = [consent.disabled containsObject:@"cookies"];
// etc
import games.my.mrgs.didomi.MRGSDidomi;
import io.didomi.sdk.models.UserStatus;
final UserStatus userStatus = MRGSDidomi.getInstance().getUserStatus();
if (userStatus == null) {
// Didomi wasn't initialized or ready
return;
}
final UserStatus.Purposes purposes = userStatus.getPurposes();
// You can also check Consent and Legitimate Interest statuses.
final UserStatus.Ids consent = purposes.getConsent();
final boolean isCookiesEnabled = consent.getEnabled().contains("cookies");
final boolean isCookiesDisabled = consent.getDisabled().contains("cookies");
// etc
Checking the status of vendors🔗
To get a list of vendors and check their statuses:
var userStatus = MRGSDidomi.Instance.UserStatus;
if (userStatus == null) {
// Didomi wasn't initialized or ready
return;
}
var vendors = userStatus.Vendors;
// You can also check Consent and Legitimate Interest statuses.
var consent = vendors.Consent;
var isGoogleEnabled = consent.Enabled.Contains("google");
var isGoogleDisabled = consent.Disabled.Contains("google");
// etc
DDMUserStatus* userStatus = [MRGSDidomi sharedInstance].userStatus;
if(userStatus == nil){
// Didomi wasn't initialized or ready
return;
}
DDMUserStatusVendors* vendors = userStatus.vendors;
// You can also check Consent and Legitimate Interest statuses.
DDMUserStatusIDs* consent = vendors.consent;
BOOL isGoogleEnabled = [consent.enabled containsObject:@"google"];
BOOL isGoogleDisabled = [consent.disabled containsObject:@"google"];
// etc
import games.my.mrgs.didomi.MRGSDidomi;
import io.didomi.sdk.models.UserStatus;
final UserStatus userStatus = MRGSDidomi.getInstance().getUserStatus();
if (userStatus == null) {
// Didomi wasn't initialized or ready
return;
}
final UserStatus.Vendors vendors = userStatus.getVendors();
// You can also check their statuses.
final UserStatus.Ids consent = vendors.getConsent();
final boolean isGoogleEnabled = consent.getEnabled().contains("google");
final boolean isGoogleDisabled = consent.getDisabled().contains("google");
// etc
Events and data🔗
Table for mapping purposes with Didomi SDK🔗
| Purpose № | Meaning | Didomi SDK ID | Type |
|---|---|---|---|
| 1 | Store and/or access | cookies | Consent |
| 2 | Use limited data to select advertising | select_basic_ads | Consent, Legitimate Interest |
| 3 | Create profiles for personalized advertising | create_ads_profile | Consent |
| 4 | Use profiles to select personalized advertising | select_personalized_ads | Consent |
| 5 | Create profiles to personalize content | create_content_profile | Consent |
| 6 | Use profiles to select personalized content | select_personalized_content | Consent |
| 7 | Measure advertising performance | measure_ad_performance | Consent, Legitimate Interest |
| 8 | Measure content performance | measure_content_performance | Consent, Legitimate Interest |
| 9 | Understand audiences through statistics | market_research | Consent, Legitimate Interest |
| 10 | Develop and improve services | market_research | Consent, Legitimate Interest |
| 11 | Use limited data to select content | N/A | Consent, Legitimate Interest |
Collectable metrics🔗
MRGSDidomi SDK collects next statistics about TCF (metric name: Tracking TCF 2.0 request[-20]):
| Object ID | Meaning |
|---|---|
| 0 | Notice Displayed |
| 1 | Total User Choices |
| 2 | Opt-ins |
| 3 | Opt-outs |
| 4 | Partial opt-ins |
| 5 | 'See more' button |
| 6 | Purpose 1 |
| 7 | Purpose 3 |
| 8 | Purpose 4 |
| 9 | Consent Re-collection |
Event meaning
Notice Displayed - Total number of impressions of the TCF-banner.
Total User Choices - The total number of user agreements.
Opt-ins - User agreed with all purposes and vendors, click event on Accept button (1st layer) or on Accept All button (2nd layer) (Opt-in => all consent/legitimate interest enabled).
Opt-outs - User rejected all purposes, click event on Confirm Choices button (2nd layer), all toggles are disabled (Opt-out => all consent/legitimate interest disabled).
Partial opt-ins - Click event on Confirm Choices button on the 2nd layer with at least one switch turned off or on (At least 1 consent/legitimate interest differs from other choices).
'See more' button - Click event on See more button, switching from the first layer to the second.
Purpose 1 - User agreed with Purpose 1 (Store and/or access).
Purpose 3 - User agreed with Purpose 3 (Create profiles for personalized advertising).
Purpose 4 - User agreed with Purpose 4 (Use profiles to select personalized advertising).
Consent Re-collection - Repeatable events of showing TCF banner to users.
Show ads
Projects has to implement logging of events of clicking on the “Show ads” button themselves.
Example🔗
using MRGS;
namespace Sample
{
internal class DidomiExample
{
public class InitManager : MRGSDidomi.IDelegate
{
private bool _shouldInit = true;
// After GDPR accepted
public void OnInit()
{
// Setup delegate
MRGSDidomi.Instance.Delegate = this;
// Init didomi
MRGSDidomi.Instance.Setup(new MRGSDidomiInitializeParameters("<API_KEY>", noticeId: "<NOTICE>"));
// Showing notice on app start (recommended by Didomi)
// Or you can show it when needed
MRGSDidomi.Instance.ShowNotice();
}
public void OnReceiveConsentStatus()
{
var acceptedAds = MRGSDidomi.Instance.HasAcceptedAdvertising;
var acceptedPersonalizedAds = MRGSDidomi.Instance.HasAcceptedPersonalizedAdvertising;
if (acceptedAds)
{
// Init sdks if needed (delegate can be called multiple times for session)
if (_shouldInit)
{
_shouldInit = false;
IronSource.Agent.init("<APP_KEY>");
}
// Set consents to sdks
IronSource.Agent.setConsent(acceptedPersonalizedAds);
}
}
}
/// <summary>
/// View with button to show ad
/// </summary>
public class AdViewManager
{
public void OnShowAd()
{
var acceptedAds = MRGSDidomi.Instance.HasAcceptedAdvertising;
if (acceptedAds)
{
// Show loaded ad
}
else
{
// Show explaining window
// ...
MRGSDidomi.Instance.ShowPreferences();
// If you don't show notice at app start,
// then you need to show it here:
// if (!MRGSDidomi.Instance.HasAcceptedAgreement)
// {
// MRGSDidomi.Instance.ShowNotice();
// }
// else
// {
// MRGSDidomi.Instance.ShowPreferences();
// }
}
}
}
/// <summary>
/// Settings window in app
/// </summary>
public class SettingsViewManager
{
public bool ShouldShowTcfSettingsButton()
{
return MRGSDidomi.Instance.IsConsentRequired;
}
public void OnShowTCF()
{
MRGSDidomi.Instance.ShowPreferences();
}
}
}
}
@interface InitManager: UIViewController <MRGSDidomiDelegate>
@property (nonatomic) BOOL shouldInit;
@end
@implementation InitManager
// After GDPR accepted
-(void)onInit{
// Setup delegate
[MRGSDidomi sharedInstance].delegate = self;
// Init didomi
DidomiInitializeParameters* params = [[DidomiInitializeParameters alloc] initWithApiKey:@"<AppKey>"
localConfigurationPath:nil
remoteConfigurationURL:nil
providerID:nil
disableDidomiRemoteConfig:NO
languageCode:nil
noticeID:@"<NoticeId>"];
[[MRGSDidomi sharedInstance] setupWithParams:params];
// Showing notice on app start (recommended by Didomi)
// Or you can show it when needed
[[MRGSDidomi sharedInstance] showNoticeAtViewController:self];
}
- (void)didReceiveConsentStatus {
BOOL acceptedAds = [MRGSDidomi sharedInstance].hasAcceptedAdvertising;
BOOL acceptedPersonalizedAds = [MRGSDidomi sharedInstance].hasAcceptedPersonalizedAdvertising;
if (acceptedAds) {
// Init sdks if needed (delegate can be called multiple times for session)
if (_shouldInit) {
_shouldInit = false;
[IronSource initWithAppKey:@"<APP_KEY>"];
}
// Set consents to sdks
[IronSource setConsent:acceptedPersonalizedAds];
}
}
@end
/// View with button to show ad
@interface AdViewManager: UIViewController
@end
@implementation AdViewManager
-(void)onShowAd{
BOOL acceptedAds = [MRGSDidomi sharedInstance].hasAcceptedAdvertising;
if (acceptedAds) {
// Show loaded ad
} else {
// Show explaining window
// ...
[[MRGSDidomi sharedInstance] showPreferencesAtViewController:self forView:ViewsPurposes];
// If you don't show notice at app start,
// then you need to show it here:
// if (![MRGSDidomi sharedInstance].hasAcceptedAgreement) {
// [[MRGSDidomi sharedInstance] showNoticeAtViewController:self];
// } else {
// [[MRGSDidomi sharedInstance] showPreferencesAtViewController:self forView:ViewsPurposes];
// }
}
}
@end
/// Settings window in app
@interface SettingsViewManager: UIViewController
@end
@implementation SettingsViewManager
-(BOOL)shouldShowTcfSettingsButton {
return [MRGSDidomi sharedInstance].isConsentRequired;
}
-(void)onShowTCF{
[[MRGSDidomi sharedInstance] showPreferencesAtViewController:self forView:ViewsPurposes];
}
@end
import android.app.Activity;
import android.content.Context;
import androidx.fragment.app.FragmentActivity;
import com.ironsource.mediationsdk.IronSource;
import games.my.mrgs.didomi.MRGSDidomi;
import games.my.mrgs.didomi.MRGSDidomiListener;
import io.didomi.sdk.DidomiInitializeParameters;
class DidomiExample {
public class InitManager implements MRGSDidomiListener {
private boolean shouldInit = true;
// After GDPR accepted
public void onInit () {
// Setup delegate
MRGSDidomi.getInstance().setOnDidomiListener(this);
// Init didomi
MRGSDidomi.getInstance().setup(Context, DidomiInitializeParameters);
// Showing notice on app start (recommended by Didomi)
// Or you can show it when needed
MRGSDidomi.getInstance().showNotice(FragmentActivity);
}
@Override
public void onReceiveConsentStatus() {
final boolean acceptedAds = MRGSDidomi.getInstance().hasAcceptedAdvertising();
final boolean acceptedPersonalizedAds = MRGSDidomi.getInstance().hasAcceptedPersonalizedAdvertising();
if (acceptedAds) {
// Init sdks if needed (delegate can be called multiple times for session)
if (shouldInit) {
shouldInit = false;
IronSource.init(Activity, "<APP_KEY>", ...);
}
// Set consents to sdks
IronSource.setConsent(acceptedPersonalizedAds);
}
}
}
/// <summary>
/// View with button to show ad
/// </summary>
public class AdViewManager {
public void onShowAd() {
final boolean acceptedAds = MRGSDidomi.getInstance().hasAcceptedAdvertising();
if (acceptedAds) {
// Show loaded ad
} else {
// Show explaining window
// ...
MRGSDidomi.getInstance().showPreferences(FragmentActivity);
// If you don't show notice at app start,
// then you need to show it here:
//if (!MRGSDidomi.getInstance().hasAcceptedAgreement()) {
// MRGSDidomi.getInstance().showNotice(FragmentActivity);
//} else {
// MRGSDidomi.getInstance().showPreferences(FragmentActivity);
//}
}
}
}
/// <summary>
/// Settings window in app
/// </summary>
public class SettingsViewManager {
public boolean shouldShowTcfSettingsButton() {
return MRGSDidomi.getInstance().isConsentRequired();
}
public void onShowTCF() {
MRGSDidomi.getInstance().showPreferences(FragmentActivity);
}
}
}
Created: 2024-01-29