I’ve been just lately experimenting with integrating advertisements into my purposes as an experiment. Not actually to earn a living, however to only get it setup and dealing. I just lately experimented with each Facebook Ads and Google AdMob for my iOS app “Social Post” and the outcomes have been fairly good. I mentioned this technique a number of weeks again on the Merge Conflict podcast with Frank on Monitization.
Now, it’s time to go a step additional and add some advertisements into my Xamarin.Forms utility Meetup Manager that has a number of utilization. I knew I needed to replace the app due to adjustments in Android N with SQLite, so I determine what higher time. I used to be stunned how straightforward it was to really get issues setup and working.
Registring with AdMob
So, the very first thing that you will want to do is definitely register for AdMob. This gives you two necessary items of knowledge, your “Application Code” and your “Ad Unit Id”. We will use these later, however merely go to: https://apps.admob.com, register for a brand new app, hyperlink to an app in Firebase, and you may be off working.
Downloading NuGet Package
This one is a bit tough since Xamarin.Forms requires very particular package deal variations. Search for “Google Play Ads” and the Xamarin package deal ought to be the primary one to return up. If you might be utilizing Xamarin.Forms.Maps then you need to choose 126.96.36.199, else you’ll be able to choose 188.8.131.52. (Note, that in case you are focusing on API 24+ you’ll be able to set up newer help libraries after which set up 42.1021.1+ of the advertisements sdk :))
For my utility I’m not including any customized information bindings or something like that for the Ad Ids, so I simply create a really very quite simple customized management in my shared code:
Ad View Renderer
Now, now we have to enter our Android undertaking and implement the customized management. Essentially only a methodology to create the native AdView after which set it when the web page masses up.
Go into your Main Activity and initialize your CellularAds from the SDK:
You will now want so as to add 2 permissions:
Inside of the Application attribute you must add this particular Activity for advertisements.
Now we will add the customized management to the underside of your XAML.
First add your customized xmlns identify house:
Then add in the customized management and growth completed!
You ought to now have the ability to run your app and growth! Test Ad!
This in fact was only a sensible banner, however you could possibly lengthen it even additional and check out the opposite advertisements with customized renderers. Enjoy! Looking so as to add AdMob advertisements to iOS apps? I’ve you lined in my next blog found here.