AdMob Mediation - iOS

I am using the AdMob component provided by Xamarin.

I would like to include iAd adverts using the AdMob mediation and cannot find any information for adding the iAd adaptor to the Xamarin AdMob component.

So my question is: How do I add the iAd adaptor to the Xamarin AdMob component?

Answers

  • GarethWerrenGarethWerren GBMember

    This is a Xamarin provided component with no answer in two days whilst other questions regarding Xamarin provided components have had answers from Xamarin employees in a matter of hours. This is a shame as my other experiences of Xamarin have been very positive (something I tell anyone who will listen).

    Although instructions for implementing the adaptor would be nice just a simple response would also be helpful, for instance:

    • Does the Xamarin AdMob component even theoretically support third party ad adaptors or has this not been exposed - if not then I can look elsewhere

    • If the component does theoretically support adaptors any guidance would be appreciated (do I need to create my own bindings and assign an instance somehow for instance).

    • Or is the Xamarin AdMob component actually a "swiss army knife" and contain all (or a popular sub-set) of the adaptors and I need do nothing more?

  • GarethWerrenGarethWerren GBMember

    For anyone else out there looking for a solution to this problem I have succeeded by doing the following:

    • Disclaimer: I have no prior experience with ObjC bindings so there may be a better way :)

    You will need to build the AdMob component manually from source. The source appears to be on GitHub - it is slightly out of date (as of writing the version on GitHub targets version 6.8 of the AdMob API from google, the actual version available and the version linked to by the version in the component store is 6.9.2) but since the commits are by Xamarin employees and it has the same sample project as the version on the component store I am assuming it is the same.


    To Build:

    1. Get the latest code from https://github.com/mono/monotouch-bindings/tree/master/GoogleAdMobAds

    2. Modify bindings/Makefile and change the VERSION=... line to the latest version, you may also need to change some of the path names in the zip file that gets downloaded - if in doubt download the AdMob SDK zip file from Google and look inside

    3. Run make from the command line in the GoogleAdMobAds directory to build. If like me you do not have a pro licence yet (on my list when I have the money :)) it will fail at the build step - just open the .csproj file in the binding folder in Xamarin Studio and build (in release mode).

    Alternative Steps 2 and 3. Download the AdMob SDK from Google and place the libGoogleAdMobAds.a file in the binding folder then open the .csproj file from the bindings folder and build (in release mode).


    To add in the iAd adaptor

    All that the iAd adaptor needs in order to be used is to be included in the project along with the AdMob SDK. The AdMob SDK will automatically pick it up and use it as defined by your AdMob mediation settings.

    1. Download the iAd adaptor from the mediation networks page: https://developers.google.com/mobile-ads-sdk/docs/admob/mediation-networks and extract the libAdapterIAd.a file to the bindings folder of the Xamarin AdMob component

    2. Using Xamarin Studio add the newly downloaded adaptor to the AdMob bindings project.

    3. A .linkwith.cs sub file should be automatically added under the libAdapterIAd.a file (I found two links would be added but they would point to the same file, this appears to be a Xamarin Studio oddity - you can either ignore it which seems to be fine or close and reopen the solution which should then only display the one link). You should edit this file and change the assembly attribute line to the following:

    [assembly: LinkWith ("libAdapterIAd.a", LinkTarget.Simulator | LinkTarget.ArmV7 | LinkTarget.ArmV7s, SmartLink = true, ForceLoad = true, Frameworks = "iAd", LinkerFlags = "-ObjC")]

    1. Build the AdMob dll (in release mode) and use this in your project in place of the Xamarin Component Store version.

    To test iAd mediation I set up mediation in the AdMob control panel and gave iAd a $10 eCPM to give it preference - doing this I then saw iAd adverts (very obvious as they are the test ones advertising the iAd platform) with a few non-iAd ones interspersed. All seems to work fine.

    Side Note: I wondered if I could host the iAd adaptor in a separate bindings project and use the Xamarin Component Store project for the main bindings - a quick trial of this seems to suggest that it does not work (but this may simply be that I do not know enough about how bindings work).

  • AlexSotoAlexSoto MXXamarin Team Xamurai

    Hello @GarethWerren‌

    I am the author of Google AdMob Xamarin Component sorry for the late response. Will look into including this plugins either as a separated components or built in into the AdMob Component.

    Thanks for the heads up

    Alex

  • GarethWerrenGarethWerren GBMember

    Hi @dalexsoto‌

    No worries - took me a while to figure it out but it's always good to learn new things :)

    The one thing I was thinking about was the fact that I could not get it to work with the iAd plugin linked to a separate C# project to the main AdMob component bindings project. I don't know if this was just my configuration causing problems or if it was related to the way google include the plugins as part of the build with no user code being required.

    If it is the latter I was wondering whether a good solution would be to use the new Shared Project approach and have the AdMob bindings in a single shared project and other mediation plugins in their own shared projects. This way users could simply reference the projects they want in order to get the plugins they require. Not sure if this would fit in with the current Xamarin Component Store model though.

  • RussellCollinghamRussellCollingham GBUniversity ✭✭

    Hi, @GarethWerren I'm trying to follow your instructions by building the bindings in XS. This produces a DLL. When I add a reference to that DLL and build in my solution I get the following errors:

    <br /> Error 2 Native linking error: warning: ignoring file /Users/voxdev/Library/Caches/Xamarin/mtbs/builds/XXXiOS/5e2f936e5170e09704aab412fadd7d19/obj/iPhone/Debug/mtouch-cache/libAdmobExporter.a, file was built for unsupported file format ( 0x0A 0x0A 0x0A 0x0A 0x3C 0x21 0x44 0x4F 0x43 0x54 0x59 0x50 0x45 0x20 0x68 0x74 ) which is not the architecture being linked (armv7): /Users/voxdev/Library/Caches/Xamarin/mtbs/builds/XXXeiOS/5e2f936e5170e09704aab412fadd7d19/obj/iPhone/Debug/mtouch-cache/libAdmobExporter.a XXX.iOS<br /> Error 3 Native linking failed, undefined Objective-C class: <em>OBJC_CLASS</em>$<em>EKEvent. If '_OBJC_CLASS</em>$<em>EKEvent' is a protocol from a third-party binding, please check that it has the [Protocol] attribute in its api definition file, otherwise verify that all the necessary frameworks have been referenced and native libraries are properly linked in. XXX.iOS<br /> Error 4 Native linking failed, undefined Objective-C class: _OBJC_CLASS</em>$<em>EKEventEditViewController. If '_OBJC_CLASS</em>$_EKEventEditViewController' is a protocol from a third-party binding, please check that it has the [Protocol] attribute in its api definition file, otherwise verify that all the necessary frameworks have been referenced and native libraries are properly linked in. XXX.iOS<br /> Error 5 Native linking failed. Please review the build log. XXX.iOS</p> <p>

    Any ideas?
    Thanks

  • GarethWerrenGarethWerren GBMember

    Hi @RussellCollingham,

    I'm not really sure about these errors, I got the component building for my app and have not touched it or updated it since and I do not know much about obj-c binding. My best guesses are that either:

    1. The Google component and the Xamarin wrapper code are out of sync, hence you are getting errors about missing classes

    or

    1. The references in the C# code may be pointing at the wrong places for the .a files

    Sorry I can't be of more help here, maybe @dalexsoto‌ or one of the Xamarin team may be able to shed more light on the errors.

  • RussellCollinghamRussellCollingham GBUniversity ✭✭

    Thanks for replying :) This is a java - android binding, I've not got around to trying the iOS version yet, but I did notice some people have succeeded so I will give that a try later.

    Definitely something is missing though, this is a .cs file created in the bindings project
    <br /> namespace Com.Vungle.Publisher.Protocol.Message {</p> <pre><code>// Metadata.xml XPath class reference: path="/api/package[@name='com.vungle.publisher.protocol.message']/class[@name='JsonDeserializationFactory']" [global::Android.Runtime.Register ("com/vungle/publisher/protocol/message/JsonDeserializationFactory", DoNotGenerateAcw=true)] public abstract partial class JsonDeserializationFactory : global::Com.Vungle.Publisher.Protocol.Message.MessageFactory {


    The last line shows the reference to the MessageFactory. It doesn't appear elsewhere in the generated cs files.

    I have contacted Vungle to see if they have any ideas.

    I had no problems with Chartboost, works like a dream.

    Thanks

  • RussellCollinghamRussellCollingham GBUniversity ✭✭

    Doh ignore the above, I have a different thread in the android forum relating to Vungle, thought you'd answered that one. Apologies.

    Thank you for answering.

  • MilanGohilMilanGohil USMember

    Hi,

    I am creating one android app in which I am showing Google Ad Mob ads using "Google Play Services" Xamarin component.
    Ad Mob displays ads using Ad mob network.
    Now I want to use AdMob mediation feature to pull the ads from multiple ad networks.
    I added MobFox and Mopub ad networks and their respective Ad Unit Ids under mediation in AdMob.

    Actually There is no detailed description given about using mediation in Xamarin.

    Now my Question are :
    1) Is this sufficient to pull out the ads from MobFox and Mopub ad networks?
    2) Do I need to add MobFox and Mopub sdk's in my project? How will it work with Xamarin?
    3) Can someone provide me the steps to make this working?

    Thanks
    Milan Gohil

  • zahikramerzahikramer ILMember ✭✭✭

    hi @MilanGohil
    Did you find an answer?

  • VictorHGarciaVictorHGarcia USUniversity ✭✭
    edited December 2015

    Is there a way or guide to know how to add the Ad Network adapters into the Xamarin.iOS project? I'm using Xamarin.Google.iOS.MobileAds and I'm getting this error:

    Cannot find an ad network adapter with the name(s): (
    "com.google.DummyAdapter"
    ). Remember to link all required ad network adapters and SDKs, and set -ObjC in the 'Other Linker Flags' setting of your build target.

    Thanks

Sign In or Register to comment.