|
| 1 | +--- |
| 2 | +layout: manual |
| 3 | +language: en |
| 4 | +github: https://github.com/defold/extension-adinfo |
| 5 | +title: Defold advertising info extension API documentation |
| 6 | +brief: This manual covers how to get the advertising id and status on iOS and Android in Defold. |
| 7 | +--- |
| 8 | + |
| 9 | +# Defold advertising info extension API documentation |
| 10 | + |
| 11 | +This extension provides a unified, simple to use interface to get the advertising id and status on iOS and Android. |
| 12 | + |
| 13 | + |
| 14 | +## Installation |
| 15 | +To use this library in your Defold project, add the following URL to your `game.project` dependencies: |
| 16 | + |
| 17 | +https://github.com/defold/extension-adinfo/archive/master.zip |
| 18 | + |
| 19 | +We recommend using a link to a zip file of a [specific release](https://github.com/defold/extension-adinfo/releases). |
| 20 | + |
| 21 | + |
| 22 | +## Configuration |
| 23 | +The extension can be configured by adding the following fields to game.project: |
| 24 | + |
| 25 | +``` |
| 26 | +[adinfo] |
| 27 | +tracking_usage_description = We would like to show you relevant ads. |
| 28 | +register_for_attribution = 1 |
| 29 | +``` |
| 30 | + |
| 31 | +### tracking_usage_description |
| 32 | + |
| 33 | +Before requesting advertising info and status on iOS 14 the application must request user authorization to access app-related data for tracking the user or the device. This is done automatically when `adinfo.get()` is called. The string set in `adinfo.tracking_usage_description` will be shown to the user. |
| 34 | + |
| 35 | +Apple documentation: https://developer.apple.com/documentation/apptrackingtransparency?language=objc |
| 36 | + |
| 37 | +Note: If this field is omitted the generated `Info.plist` file will not contain a `<key>NSUserTrackingUsageDescription</key>` key and value. |
| 38 | + |
| 39 | +### register_for_attribution |
| 40 | + |
| 41 | +The extension can automatically register the application for ad network attribution using `SkAdNetwork` and the `registerAppForAdNetworkAttribution()` function. Enable this functionality by setting `adinfo.register_for_attribution` to 1 in game.project. |
| 42 | + |
| 43 | +Apple documentation: https://developer.apple.com/documentation/storekit/skadnetwork |
| 44 | + |
| 45 | + |
| 46 | +## Example |
| 47 | + |
| 48 | +```lua |
| 49 | +function init(self) |
| 50 | + adinfo.get(function(self, info) |
| 51 | + print(info.ad_ident, info.ad_tracking_enabled) |
| 52 | + end) |
| 53 | +end |
| 54 | +``` |
| 55 | + |
| 56 | +## Source code |
| 57 | + |
| 58 | +The source code is available on [GitHub](https://github.com/defold/extension-adinfo) |
| 59 | + |
| 60 | + |
| 61 | +## API reference |
| 62 | +[API Reference - adinfo](/extension-adinfo/adinfo_api) |
0 commit comments