-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Moloco Native Ad: Add support for native ads for the Moloco SDK #549
base: main
Are you sure you want to change the base?
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
df7bb1d
to
0634a9f
Compare
0634a9f
to
430a4a9
Compare
MediationAdLoadCallback<UnifiedNativeAdMapper, MediationNativeAdCallback>, | ||
// TODO: Add other parameters or remove unnecessary ones. | ||
) : UnifiedNativeAdMapper() { | ||
MediationAdLoadCallback<UnifiedNativeAdMapper, MediationNativeAdCallback>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are trying to replace UnifiedNativeAdMapper
with NativeAdMapper
, could you please update to that class instead? https://developers.google.com/android/reference/com/google/android/gms/ads/mediation/NativeAdMapper
} | ||
|
||
companion object { | ||
fun newInstance( | ||
mediationNativeAdConfiguration: MediationNativeAdConfiguration, | ||
mediationNativeAdLoadCallback: | ||
MediationAdLoadCallback<UnifiedNativeAdMapper, MediationNativeAdCallback>, | ||
MediationAdLoadCallback<UnifiedNativeAdMapper, MediationNativeAdCallback>, | ||
): Result<MolocoNativeAd> { | ||
val context = mediationNativeAdConfiguration.context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I see the context being used anywhere, so it is safe to delete.
|
||
/** | ||
* Used to load Moloco native ads and mediate callbacks between Google Mobile Ads SDK and Moloco | ||
* SDK. | ||
*/ | ||
class MolocoNativeAd | ||
private constructor( | ||
private val context: Context, | ||
private val adUnitId: String, | ||
private val nativeAdOptions: NativeAdOptions, // TODO: Not sure where to use this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can take a look at what options are in this class and map them to any configuration that can be added to Moloco's NativeAds https://developers.google.com/admob/android/native/options. I dare say, video options is one of common interest for many ad networks.
private val drawable: Drawable, | ||
private val uri: Uri = Uri.EMPTY, | ||
private val scale: Double = 1.0, | ||
) : com.google.android.gms.ads.formats.NativeAd.Image() { // Google deprecated the class, but didn't offer an alternative. So for now we *must* use the deprecated class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the UnifiedNativeAdMapper
is updated to NativeAdMapper
, the non-deprecated class can be used: https://developers.google.com/android/reference/com/google/android/gms/ads/nativead/NativeAd.Image
Summary
NOTE: Please do the E2E verification before merging this change in. I had trouble establishing the build dependencies and prepared the adapter from our internal source without being able to compile the google project.
Testing
Added unit tests and all tests pass
![Screenshot 2025-02-05 at 4 16 15 PM](https://private-user-images.githubusercontent.com/137231605/410233905-5dd4bb81-6e61-45be-8b15-7ac669e9859c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2NzUxNTYsIm5iZiI6MTczOTY3NDg1NiwicGF0aCI6Ii8xMzcyMzE2MDUvNDEwMjMzOTA1LTVkZDRiYjgxLTZlNjEtNDViZS04YjE1LTdhYzY2OWU5ODU5Yy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxNlQwMzAwNTZaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05ODgzY2U3MTFjMjI1ZTRlMDBlM2Q3N2VhNjJiMGQ0M2E4MzFlYmM1ZmUyMWFhMjYyYjIyNTU5MjE4MjQ1M2I0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.yyuAzAnJp3HcB3onDTtihj7QMxILaVc5nZqZYc2uxas)