AppLovin / AppLovin-MAX-SDK-iOS

Other
91 stars 73 forks source link

requesting landscape or portrait #78

Closed mmdock closed 2 years ago

mmdock commented 2 years ago

I am a little confused on how to request landscape images vs portrait.

this simply makes integrating into various parts of my app, to have the ad appear native, rather difficult.

There is nothing in applovin documentation, despite mopub, admob, and other networks where mediation is supported, having this functionality

Screen Shot 2022-03-16 at 10 33 38 AM
thomasmso commented 2 years ago

We currently do not support targeting native ads of specific aspect ratios. We will, however, provide an API in the future that you can use to retrieve the underlying media view's aspect ratio.

mmdock commented 2 years ago

We currently do not support targeting native ads of specific aspect ratios. We will, however, provide an API in the future that you can use to retrieve the underlying media view's aspect ratio.

so the goal here is, if it doesn't match our desired landscape vs portrait, we can simply choose not to display?

thomasmso commented 2 years ago

@mmdock - We just pushed SDK v11.4.0 with this API. Supported networks include AppLovin, AdMob, GAM, Facebook, myTaget, Yahoo.

https://github.com/AppLovin/AppLovin-MAX-SDK-iOS/releases/tag/release_11_4_0

ddaddy commented 2 years ago

How do we use this? Is it to inform us of the aspectRatio or for us to request a specific aspectRatio? I use a MANativeAdLoader to load an add into a MANativeAdView subclass. This in turn calls the delegate method didLoadNativeAd(_ nativeAdView: MANativeAdView?, for ad: MAAd) so I am failing to see where I access -[MANativeAd mediaContentAspectRatio] to read or set the aspectRatio?

tiandrew commented 2 years ago

@ddaddy It is to inform you of the aspect ratio if provided by the network. You can access the aspect ratio property from the MANativeAd object, which you can retrieve from our MAAd returned in the didLoadNativeAd: callback. For example:


func didLoadNativeAd(_ nativeAdView: MANativeAdView?, for ad: MAAd)
{
    if let nativeAd = ad.nativeAd
    {
        let aspectRatio = nativeAd.mediaContentAspectRatio
    }
    ...
}
ddaddy commented 2 years ago

Great, thanks. Is it too late at that point to use a different MANativeAdView? It'd be good to be able to use a different layout for portrait than landscape ads. But you have to provide the view when requesting the ad.

tiandrew commented 2 years ago

At that point the MANativeAdView would already be populated with the assets, so yes it would be too late. But what you can do is resize or rotate the media view accordingly

ddaddy commented 2 years ago

Thank you. 1 final question I hope. This returns a Float. I am seeing 0.75 for the test ad. What other figures would be returned? I assume the test ad (shown in the first post) is actually landscape as it has the black borders added to the image. So what value would we receive for portrait?

tiandrew commented 2 years ago

@ddaddy from my testing, I typically saw a 1.19 aspect ratio being returned (which would be landscape). I believe the media content that returns 0.75 as the aspect ratio would be the portrait ones, as aspect ratio is width divided by height.

ddaddy commented 2 years ago

In that case, we can probably assume >1 = landscape <1 = portrait

ddaddy commented 2 years ago

I'm only actually seeing 0.0 now for Google AdMob Native and MINTEGRAL_NATIVE_BIDDING. Not sure if something broke in the latest update?

thomasmso commented 2 years ago

For AdMob, we simply grab the aspect ratio from their SDK. You are welcome to drag-and-drop the adapter code into your project to debug though. For Mintegral - their SDK does not have support.