Class TAds
Unit
Declaration
type TAds = class(TComponent)
Description
Advertisements in game. Right now only on Android (does nothing on other platforms, as CastleMessaging does nothing on non-Android platforms).
Usage:
Create an instance of this class (only a single instance allowed).
Initialize at least one ad network using one of the
InitializeXxxmethods. Usually you want to call the initialization from TCastleApplication.OnInitialize.Use remaining methods of this class to show / hide ads, like ShowFullScreenAd, ShowBanner, HideBanner.
To include the necessary integration code in your Android project, add the appropriate services (admob, chartboost, startapp...) inside CastleEngineManifest.xml . See https://castle-engine.io/android_services .
Source: services/castleads.pas (line 99).
Hierarchy
- TObject
- TPersistent
- TComponent
- TAds
Overview
Methods
| Protected | procedure FullScreenAdClosed(const WatchedStatus: TAdWatchStatus); virtual; |
| Protected | procedure ConsentGathered(const ACanRequestAds, APrivacyOptionsRequired: Boolean; const ErrorCode: Integer); virtual; |
| Public | constructor Create(AOwner: TComponent); override; |
| Public | destructor Destroy; override; |
| Public | procedure InitializeAdMob(const BannerUnitId, InterstitialUnitId, RewardedUnitId: string; const TestDeviceIds: array of string); overload; |
| Public | procedure InitializeAdMob(const BannerUnitId, InterstitialUnitId: string; const TestDeviceIds: array of string); overload; |
| Public | procedure InitializeAdMobWithConsent( const BannerUnitId, InterstitialUnitId, RewardedUnitId: string; const TestDeviceIds: array of string; const DebugForceEea: Boolean; const DebugDeviceHashes: array of string); overload; |
| Public | procedure InitializeAdMobWithConsent( const BannerUnitId, InterstitialUnitId, RewardedUnitId: string; const TestDeviceIds: array of string); overload; |
| Public | procedure ShowConsentPrivacyOptions; |
| Public | procedure ResetConsent; |
| Public | procedure InitializeStartapp(const AppId: string); |
| Public | procedure InitializeChartboost(const AppId, AppSignature: string); |
| Public | procedure ShowFullScreenAd(const AdNetwork: TAdNetwork; const AdType: TFullScreenAdType; const WaitUntilLoaded: boolean); |
| Public | procedure ShowBanner(const AdNetwork: TAdNetwork; const HorizontalGravity: THorizontalPosition; const VerticalGravity: TVerticalPosition); |
| Public | procedure HideBanner(const AdNetwork: TAdNetwork); |
Properties
| Public | property OnFullScreenAdClosed: TAdClosedEvent
read FOnFullScreenAdClosed write FOnFullScreenAdClosed; |
| Public | property OnConsentGathered: TConsentGatheredEvent
read FOnConsentGathered write FOnConsentGathered; |
| Public | property CanRequestAds: Boolean read FCanRequestAds; |
| Public | property PrivacyOptionsRequired: Boolean read FPrivacyOptionsRequired; |
| Public | property BannerSize: TRectangle read FBannerSize; |
Description
Methods
| Protected | procedure FullScreenAdClosed(const WatchedStatus: TAdWatchStatus); virtual; |
|
This item has no description. | |
| Protected | procedure ConsentGathered(const ACanRequestAds, APrivacyOptionsRequired: Boolean; const ErrorCode: Integer); virtual; |
|
Called when the user consent was gathered, see TConsentGatheredEvent. | |
| Public | constructor Create(AOwner: TComponent); override; |
|
This item has no description. | |
| Public | destructor Destroy; override; |
|
This item has no description. | |
| Public | procedure InitializeAdMob(const BannerUnitId, InterstitialUnitId, RewardedUnitId: string; const TestDeviceIds: array of string); overload; |
|
Initialize AdMob ads. You need to create the unit ids on AdMob website (or use TestAdMobBannerUnitId, TestAdMobInterstitialUnitId for testing). This is usually called from TCastleApplication.OnInitialize. Parameters
| |
| Public | procedure InitializeAdMob(const BannerUnitId, InterstitialUnitId: string; const TestDeviceIds: array of string); overload; |
|
This item has no description. | |
| Public | procedure InitializeAdMobWithConsent( const BannerUnitId, InterstitialUnitId, RewardedUnitId: string; const TestDeviceIds: array of string; const DebugForceEea: Boolean; const DebugDeviceHashes: array of string); overload; |
|
Initialize AdMob ads, gathering the user consent first, using the Google User Messaging Platform (UMP). Google requires a consent management platform for the users in the European Economic Area and the UK, and requires that no ad is requested before such user has answered the consent form. This method does exactly that: the consent form is shown when it is required, and the ads SDK is initialized only once the answer allows requesting ads. Where no consent is required, e.g. outside of Europe, nothing is shown to the user and the ads are initialized right away. The consent messages have to be configured in your AdMob account first, see https://support.google.com/admob/answer/10113005 . When the consent has been gathered, OnConsentGathered is called and CanRequestAds, PrivacyOptionsRequired are updated. Note that this does not make your application compliant by itself. In particular, when PrivacyOptionsRequired is
Usually called from TCastleApplication.OnInitialize, instead of InitializeAdMob. Parameters
| |
| Public | procedure InitializeAdMobWithConsent( const BannerUnitId, InterstitialUnitId, RewardedUnitId: string; const TestDeviceIds: array of string); overload; |
|
Initialize AdMob ads, gathering the user consent first, without the testing parameters. | |
| Public | procedure ShowConsentPrivacyOptions; |
|
Show the form that lets the user change or withdraw the consent given earlier. Show it from your own entry point (e.g. a button in the settings) whenever PrivacyOptionsRequired is | |
| Public | procedure ResetConsent; |
|
Forget the gathered consent, so that the next application run asks again. Testing only. | |
| Public | procedure InitializeStartapp(const AppId: string); |
|
Initialize StartApp ads. You need to register your game on http://startapp.com/ to get app id. Usually called from TCastleApplication.OnInitialize. | |
| Public | procedure InitializeChartboost(const AppId, AppSignature: string); |
|
Initialize Chartboost ads. You need to register your game on http://chartboost.com/ to get app id and signature. Usually called from TCastleApplication.OnInitialize. | |
| Public | procedure ShowFullScreenAd(const AdNetwork: TAdNetwork; const AdType: TFullScreenAdType; const WaitUntilLoaded: boolean); |
|
Show full-screen ad, interstitial (in-between) or reward ad. Not all ad networks support (or differentiate between) all full-screen ad types possible in TFullScreenAdType enumeration. So we eventually show other sensible ad type instead. If WaitUntilLoaded, then we wait until the ad contents are fetched (be sure to show some "loading" state to user, as it may take a while in case of a slow network). If not WaitUntilLoaded, then we immediately resign if ad is not loaded yet. Not all ad implementations support this setting reliably, so this is only a suggestion. In any case, after this method is called, we make sure to call callback OnFullScreenAdClosed sometime. | |
| Public | procedure ShowBanner(const AdNetwork: TAdNetwork; const HorizontalGravity: THorizontalPosition; const VerticalGravity: TVerticalPosition); |
|
Show banner ad. Banners are not supported by all ad networks (only AdMob now), in case they are unsupported this call is silently ignored. | |
| Public | procedure HideBanner(const AdNetwork: TAdNetwork); |
|
Hide banner ad. Banners are not supported by all ad networks (only AdMob now), in case they are unsupported this call is silently ignored. | |
Properties
| Public | property OnFullScreenAdClosed: TAdClosedEvent
read FOnFullScreenAdClosed write FOnFullScreenAdClosed; |
|
This item has no description. | |
| Public | property OnConsentGathered: TConsentGatheredEvent
read FOnConsentGathered write FOnConsentGathered; |
|
Called when the user consent was gathered, see InitializeAdMobWithConsent. | |
| Public | property CanRequestAds: Boolean read FCanRequestAds; |
|
Whether we may request ads. It is | |
| Public | property PrivacyOptionsRequired: Boolean read FPrivacyOptionsRequired; |
|
Whether your application has to show an entry point calling ShowConsentPrivacyOptions. Meaningful only after the consent was gathered, see InitializeAdMobWithConsent. | |
| Public | property BannerSize: TRectangle read FBannerSize; |
|
This item has no description. | |
Generated by PasDoc 1.0.4.