Skip to main content

Custom AdChoices

A feature added in GFP SDK version 6.5.0 that supports customizing the screen that appears when clicking on GFPAdChoicesView in an S2S native ad.

info

When using custom Ad Choices, the Ad Choices icon is not rendered inside GFPAdChoicesView, so you must manually configure the Ad Choices icon in your UI.

info

This feature is not processed for native ads from C2S ad providers such as DFP, FAN, or InMobi.

enableCustomAdChoices

Sets whether to use a custom view for the native ad AdChoices view. (Default: NO) When this option is set, the SDK does not draw any view inside adChoicesView.

GFPAdNativeOptions *nativeOptions = [[GFPAdNativeOptions alloc] init];

GFPNativeAdRenderingSetting *renderingSetting = [[GFPNativeAdRenderingSetting alloc] init];
renderingSetting.enableCustomAdChoices = NO; (기본값)
renderingSetting.enableCustomAdChoices = YES;

nativeOptions.renderingSetting = renderingSetting;

AdChoices Data

Data can be obtained through adChoicesData of nativeAd. Data is only available when enableCustomAdChoices is enabled, and is only provided for S2S ads that contain adChoices information.

GFPAdChoicesData provides type, adMuteData, and privacyUrl.

type

  • AdMute: When only adMuteData exists
  • Privacy: When only privacyUrl exists
  • OptOut: When both adMuteData + privacyUrl exist

adMuteData

If adMuteData exists, the mute reason is rendered based on adMuteData. When clicked, reportClickWith: must be called.

GFPAdMuteData provides reasonCodes and textWith:, textWith:languageType:, resourceIdWith:, reportClickWith:.

reasonCodes

reasonCodes is the key value for the adMute reason and is used for text/resource ID lookup and click reporting.

GFPAdMuteData *adMuteData = nativeAd.adChoicesData.adMuteData;

[adMuteData.reasonCodes enumerateObjectsUsingBlock:^(NSString * _Nonnull reasonCode, NSUInteger idx, BOOL * _Nonnull stop) {
NSLog(@"adMuteReason: code - %@", reasonCode);
}];

adMute Reason

The reason text can be looked up by passing a reasonCode as a parameter.

When looking up a reason with textWith:, text matching the device's language setting is returned.

GFPAdMuteData *adMuteData = nativeAd.adChoicesData.adMuteData;

[adMuteData.reasonCodes enumerateObjectsUsingBlock:^(NSString * _Nonnull reasonCode, NSUInteger idx, BOOL * _Nonnull stop) {
NSString *reasonText = [adMuteData textWith:reasonCode];
NSLog(@"adMuteReason: reasonText - %@", reasonCode);
}];

When looking up a reason with textWith:languageType:, text corresponding to the languageType is returned. Supported languages are Korean, English, Spanish, French, Indonesian, Thai, Simplified/Traditional Chinese, and Japanese.

// Below version 7.2.0
GFPAdMuteData *adMuteData = nativeAd.adChoicesData.adMuteData;

[adMuteData.reasonCodes enumerateObjectsUsingBlock:^(NSString * _Nonnull reasonCode, NSUInteger idx, BOOL * _Nonnull stop) {
NSString *reasonText_ko = [adMuteData textWith:reasonCode languageType:GFPNativeLanguageType_ko];
NSLog(@"adMuteReason: reasonText_ko - %@", reasonCode, reasonText_ko);
}];
// Version 7.2.0 and above
GFPAdMuteData *adMuteData = nativeAd.adChoicesData.adMuteData;

[adMuteData.reasonCodes enumerateObjectsUsingBlock:^(NSString * _Nonnull reasonCode, NSUInteger idx, BOOL * _Nonnull stop) {
NSString *reasonText_ko = [adMuteData textWith:reasonCode languageType:GFPLanguageType_ko];
NSLog(@"adMuteReason: reasonText_ko - %@", reasonCode, reasonText_ko);
}];

reportClickWith:

When an adMute reason is clicked, pass the reasonCode as a parameter to notify that it has been clicked.

GFPAdMuteData *adMuteData = nativeAd.adChoicesData.adMuteData;
[adMuteData reportClickWith:reasonCode];

privacyUrl

If privacyUrl exists, a privacy icon must be rendered. When clicked, it must navigate to the privacyUrl.