| 1 |
## admob |
| 2 |
This service enables the AdMob banner, interstitial and rewarded advertisements. Use https://castle-engine.io/apidoc/html/CastleAds.TAds.html[TAds] class from the https://castle-engine.io/apidoc/html/CastleAds.html[CastleAds] unit to show and control the ads from your Pascal code, with `AdNetwork` set to `anAdMob`. |
| 3 |
|
| 4 |
### Requires |
| 5 |
* Using this service requires using also `google_play_services`. |
| 6 |
|
| 7 |
### App ID |
| 8 |
|
| 9 |
From Ads SDK version 17 you need use App ID to properly initialize ads. |
| 10 |
To do this in CGE you need to declare it in `CastleEngineManifest.xml` like this: |
| 11 |
|
| 12 |
[source,xml] |
| 13 |
---- |
| 14 |
<service name="admob"> |
| 15 |
<parameter key="app_id" value="..."/> |
| 16 |
</service> |
| 17 |
---- |
| 18 |
|
| 19 |
#### Test App ID |
| 20 |
If you just want test admob service you can use test app id: `ca-app-pub-3940256099942544~3347511713` |
| 21 |
|
| 22 |
### Watched status |
| 23 |
|
| 24 |
Statuses used by the admob service: |
| 25 |
|
| 26 |
[%header,cols="1,1,1"] |
| 27 |
|=== |
| 28 |
| TAdWatchStatus |
| 29 |
| AdMob errorCode equivalent |
| 30 |
| Description |
| 31 |
|
| 32 |
| wsWatched |
| 33 |
| - |
| 34 |
| The ad was displayed. |
| 35 |
|
| 36 |
| wsUnknownError |
| 37 |
| ERROR_CODE_INTERNAL_ERROR |
| 38 |
| Ad mob internal error or unknown error code. |
| 39 |
|
| 40 |
| wsNetworkNotAvailable |
| 41 |
| ERROR_CODE_NETWORK_ERROR |
| 42 |
| No internet connection. |
| 43 |
|
| 44 |
| wsNoAdsAvailable |
| 45 |
| ERROR_CODE_NO_FILL |
| 46 |
| No ads available. |
| 47 |
|
| 48 |
| wsUserAborted |
| 49 |
| - |
| 50 |
| Rewarded ad aborted by user. |
| 51 |
|
| 52 |
| wsAdNotReady |
| 53 |
| - |
| 54 |
| The ad is still loading (when we don't want to wait). |
| 55 |
|
| 56 |
| wsAdNetworkNotInitialized |
| 57 |
| - |
| 58 |
| Ad network not initialized or request for uninitialized ad type. |
| 59 |
|
| 60 |
| wsInvalidRequest |
| 61 |
| ERROR_CODE_INVALID_REQUEST |
| 62 |
| Invalid Request - bad Unit ID for example. |
| 63 |
|
| 64 |
| wsApplicationReinitialized |
| 65 |
| - |
| 66 |
| Java application was killed, but native code survived, while waiting for ad to finish. |
| 67 |
|=== |
| 68 |
|
| 69 |
### Debug |
| 70 |
|
| 71 |
If you have any problems with the admob service or want more logs, change the value of the `ServiceAdMob.debug` from `false` to `true`. |
| 72 |
Service source file is located in: |
| 73 |
`tools/build-tool/data/android/integrated-services/admob/app/src/main/java/io/castleengine/ServiceAdMob.java` |