Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yamir-godil
Copy link
Collaborator

@yamir-godil yamir-godil commented Jan 16, 2025

Summary

  • This change adds support for Moloco adapter to have Native Ad support.
  • The adapter is not tested E2E by Moloco as native ads is not enabled

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

@yamir-godil yamir-godil requested a review from thanvirm January 16, 2025 22:29
@yamir-godil yamir-godil self-assigned this Jan 16, 2025
Copy link

google-cla bot commented Jan 16, 2025

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.

@yamir-godil yamir-godil force-pushed the moloco_native_ads_support branch from df7bb1d to 0634a9f Compare January 29, 2025 19:58
@yamir-godil yamir-godil force-pushed the moloco_native_ads_support branch from 0634a9f to 430a4a9 Compare February 6, 2025 00:15
MediationAdLoadCallback<UnifiedNativeAdMapper, MediationNativeAdCallback>,
// TODO: Add other parameters or remove unnecessary ones.
) : UnifiedNativeAdMapper() {
MediationAdLoadCallback<UnifiedNativeAdMapper, MediationNativeAdCallback>,
Copy link
Collaborator

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
Copy link
Collaborator

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?
Copy link
Collaborator

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.
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants