|
1 | 1 | # Android_AdNetworks_PrioritiesManager_with_RemoteControl
|
2 |
| -Handle which ad network to use via a Firebase remote config. Ad types: interstitials, rewarded. Ad networks: UnityAds (mediated or standalone), IronSource. Add other ad networks implementations. |
| 2 | + * ***How to control a multiple standalone ad networks in one place?*** |
| 3 | + * ***Maybe you need to use multiple mediation SDKs? How to set network priority?*** |
| 4 | + * ***You can mix mediated SDKs with standalone SDKs or with another mediated SDKs.*** |
| 5 | + * ***Enable/disable ad network remotely. Configure display priorities.*** |
| 6 | + * ***Target countries for each ad network.*** |
| 7 | + * ***Have you been looking for a well documented sample of UnityAds & UnityMediation for Android native?*** |
| 8 | + * *My library not a mediation. Without control of mediated ads price.* |
| 9 | + |
| 10 | +Implemented ad types: interstitials, rewarded. |
| 11 | +Ad networks: UnityAds (mediated or standalone), UnityMediation, SuperAwesome, Kidoz, IronSource. |
| 12 | +Written in **Kotlin**. No UI sample. Android library. |
| 13 | + |
| 14 | +**My library will organize your common use cases for each ad network implementation that you will add.** |
| 15 | +## Use cases: |
| 16 | + 1. Handle which ad network to enable/disable via a Firebase remote config. |
| 17 | + 2. Define countries for each ad network. Currently separating LATAM region only. |
| 18 | + 3. Define min/max Android version for each ad network. |
| 19 | + 4. Processing data privacy: GDPR, CCPA, LGPD, ... |
| 20 | + 5. Processing some user & device data for better targeting: app language, country, age, gender, phone/tablet.. |
| 21 | + |
| 22 | +[](https://jitpack.io/#Almaren/Android_AdNetworks_PrioritiesManager_with_RemoteControl) |
| 23 | + |
| 24 | +## Preparing: |
| 25 | +* Add to your project build.gradle: |
| 26 | + ``` |
| 27 | + allprojects { |
| 28 | + repositories { |
| 29 | + ... |
| 30 | + maven { url 'https://jitpack.io' } |
| 31 | + } |
| 32 | + } |
| 33 | + ``` |
| 34 | + to the app build.gradle: |
| 35 | + ``` |
| 36 | + dependencies { |
| 37 | + implementation 'com.github.Almaren:Android_AdNetworks_PrioritiesManager_with_RemoteControl:1.0.1' |
| 38 | + } |
| 39 | + ``` |
| 40 | +* Add to your /android/../AndroidManifest.xml in your <activity> where the ads will be used: |
| 41 | + ``` |
| 42 | + <activity |
| 43 | + ... |
| 44 | + android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|mcc|mnc" |
| 45 | + /> |
| 46 | + ``` |
| 47 | + The necessary activities and overrides of ad networks are stored in my lib/AndroidManifest.xml. |
| 48 | + For better targeting some networks use coarse location, check if it required for you and complies with a Google policies, if so |
| 49 | + uncomment that line in the manifest. |
| 50 | + |
| 51 | +## How to use: |
| 52 | +**All methods of AdManager must be called from the main ui thread.** |
| 53 | +1. Set app ID for each network in AdManager: APP_ID_YOUR_NET_AD. |
| 54 | + Set ad unit id for each network where marked "todo set your id". |
| 55 | +2. Implement interface lib.ads.event.AdUserDeviceDataBinder, in my case implemented by MainActivity. |
| 56 | +3. First init: call AdManager.initAds() in your Activity.create(..). |
| 57 | + In my case calling it after age gate and consent dialog. At the second app launching I call it in a main page with already stored age and consent state. |
| 58 | +4. Implement your own logic in AdManager.getConsentUserData(). |
| 59 | + Implement age gate and consent dialog. Detect if user consent given for GDPR/CCPA/LGPD/PIPL. |
| 60 | +5. Enable/Disable test mode flags (marked as todo) in AdManager.createAdSources(). |
| 61 | +6. Whenever your got a user ads data & consent state -> call AdManager.setPrivacyMetaData() to update ad networks with a privacy/consent data. |
| 62 | +7. Define default ad sources and their priority in AdSourcePriorityHandler.init(). |
| 63 | + Define adSourceForLatam, or comment the content of method updatePrioritiesRegardingToUserRegion() if it's not relevant to you. |
| 64 | +8. To load and display ad unit type just call a suitable methods from the AdManager. |
| 65 | + Call dispose() on YourActivity.onDestroy(). |
| 66 | +9. Not mandatory: implement performing actions on each ad state in AdUnitBaseHandler. |
| 67 | + |
| 68 | +**Establishing Firebase remote config. (not mandatory)** *You can use the lib without firebase remote.* |
| 69 | +If your firebase project is configured skip to step #4. |
| 70 | +1. Create project in Firebase if not exist yet. |
| 71 | +2. Configure a project in Firebase Settings -> SDK setup and configuration. |
| 72 | + add release and debug SHA keys. |
| 73 | +3. Download google-services.json from a project settings and place to /YourProject/android folder. |
| 74 | + |
| 75 | +4. Navigate in Firebase project to Remote config. Add parameter "adSourcesPriority" with the following value: |
| 76 | + ``` |
| 77 | + {"IronSrc":[-1,-1],"UnityAdsMediation":[2,2],"UnityAds":[1,-1]} |
| 78 | + ``` |
| 79 | + where array values indicates: [interstitial, rewarded], |
| 80 | + -1 = disabled, 1+ - priorities, the highest is more prioritized to display first. |
| 81 | + |
| 82 | +5. Fetch once the remote config from the server whenever required by creating RemoteConfigCoordinator object, passing |
| 83 | + AdManager and just calling RemoteConfigCoordinator.fetchAllData(). |
| 84 | + |
| 85 | + |
| 86 | +____________________________________________________________________________________________________ |
| 87 | +**NOTICE:** © On modifying and expanding lib be sure to attribute the link in your code headers: |
| 88 | + https://github.com/Almaren |
| 89 | + Thank You! |
0 commit comments