Get Filthy Rich by Monetizing Your Xamarin.Forms App with AdMob

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
oop make it rain make it rain monetizing your app that's what this video is all about i'm already doing the wrap poses you see um so there's a different way to monetize your app but implementing advertisements is one of them and in this video i'm going to show you how to do just that with admob in your xamarin forms application and a very simple to use nuget that i found on the internet let's just go so before we're getting right into the code i'm going to show you this little website it's called xamarin expert you can go to it by xamarinexpert.it which is a blog post by this person i don't know what his name is i think the nougat package might be containing his name so we'll see that in a little bit um but here they write about oh here his name is actually marco troncone um so thank you so much for putting this together marco this is great so here's a blog post where he also describes how to work with this thing i'll link it in the video description of course so you can also read all about this um it has a couple of updates it tells you how to install it um so but i'm going to show you all of this in the video of course so but this is good to have as a reference of course we also have the github repository which has all these things as well here we go marco jack mt admob i don't know what it all stands for um this is probably references to his name as well um but version 1.6.1 at the time of recording only two weeks old so that is really really cool um you can sponsor him by buying him a coffee so if this is something that you are using and of course that big big bucks from the advertisings are coming on then you know just um consider sponsoring this person for all the great work that they have saved you so again here's a little bit of setup etc how to use it but we'll all see that how to do that in this video so let's actually just dive straight into that code here we are this is a familiar screen visual studio for mac 2019 on the left you can also do this on windows of course you can see the example of the main page just a file new xamarin forms application and it's running on the right on the ios simulator so let's update that title because that is what we always do at mob sample save that and with hot reload you can see your changes coming up automatically but we are missing something in this case because you know it's going to be admob sample the big bucks are coming in it's happening so before i go and update all of the ui things there's a couple of things that we need to set up first so let's do that first i'm going to stop running here for a little bit and go into our solution right click on the solution level and say manage nuget packages and we're going to look for the empty admob package here we go marktron.admob it also already has 15 000 downloads that's really cool updated only a couple of days ago i'm going to add that package added to all of your projects because it's on your shared project for the shared bits but it also needs renderers for android and ios so let's just click that i think android and ios are also the only support platforms right now so if you want to have any more support for platforms consider contributing that to this wonderful project because it's open source you can totally do that but for now it's just ios and android which is probably what most of you need anyway so when this is installing you can see this readme popping up again this will tell you a lot about what you need to set up actually one thing that is important here is you can see this i will talk about this a little bit more in all the documentation that marco is referencing you can see ids to applications or banners because your banners and and whatnot your types of advertisements will also have ids and these are test keys that you can just use so these are test keys that are provided from google so you can just use these no problem at all you can use these to test your app no problem so you can just copy this to see if it all works and then whenever you're done we will see that at the end of the video you can go into your own admob account and replace these ids so i'm just going to close this readme right now and one of the first things that he said we need to do is actually update our android manifest for android and our info plist for ios so our info plist i've opened that in visual studio code here it is and let me scroll down here and we are going to add two things uh the first one is going to be a key and that is named gad application identifier identifier which is something that he mentions in that readme and on the repo so you probably just want to copy and paste that thing so here we go slash string and the value that i'm going to use here is again a google provided app identifier here so i'll just copy this one and i think you can have different apps different ids between the different apps for android and ios but you can also just use the same so you can spot the difference between an app id and your advertisement id because here it has this little wave thing the tilled and for your advertisement things it will have a slash in this place so then you know whether you're dealing with you know your app id or an actual advertisement id so there's that and for ios we also need to do key gad is add manager app to be very honest i don't know what this does exactly but we need to have it in here with a true value so there's that we can just save this and boom we're we're done with this one um now for android we need to kind of like do the same we are going to go to the solution the android project we can do that from right here and we can just say properties android manifest whoops not this one actually i want to open it in this source code view so i right click open with and i say source code editor there we go and then this bit is important inside of your application node you will have to add something and to be honest it's a little bit complicated so i'm just going to copy it from somewhere here off the screen copy that paste it and it has this metadata node and it says android name so this is the name of our application id and this is our android value so this is again that same application id that we've just saw so i'm going to save this one as well and now our metadata is complete so that is cool then we need a little bit of initialization code to make this all work so let's again go to our solution and i'm going to go to our main activity right here that's the first one that i'm going to do and after examine forms let's just do it afterwards i don't think the order really matters but let's just do it and i'm going to say mobile ads dot initialize there we go and application context we also have to specify that context as is typical with a lot of these android plugins so we're just going to add that one you can see it actually installed these android gms ads package which is a dependency of the the nuget package that we're talking about here and i think also what's important what is noted in the admob plugin is that you have to do this thing with the permission so if you're just starting a file new application right now essentials is included and this code will also be there but if not then you might want to double check if this code is here and implement it the right way for your project so this is done this is all we need to do for android and now for ios we kind of need to do the same thing so android ios but here we're going into the app delegate which is you know the counterpart on ios and right here we're going to go to also write after examine forms and here we're going to say mobile ads dot shared instance dot start and we need to do some kind of completion handler here completion handler which is an event that's going to be triggered whenever this is completed uh let intellisense solve this for us so google.mobile ads again this just installed some package for us that will help us with my mobile ads bindings for the google packages that's all taken care of and you want to have some private void completion handler here handler which is an event handler so we need to have object sender and event arcs arcs probably something like that uh there we go oh it's not the correct one well actually let's just you know generate it for us boom there we go oh it's an initialization status okay so whoops let's just do it this way let's not throw any exceptions here i'll just leave it empty for now but whenever you're initializing this and something goes wrong you might want to check in here what that is and see if you can fix it that way so that is all we need to do for ios as well and now we can just start using it so that is pretty cool so we've updated the title that's good i'm going to remove all of these labels right here and what i'm going to do is you do this admob i actually need to import that namespace but let's just do it like this empty add view that's what the actual control is called and now i can just say again intellisense do this for me and it will add the right xml ns with the name of admob and it will figure out this namespace right here so there's that and then i can use this empty app view so that is pretty cool now i think by default it has a height of 50 or something but if it doesn't show up you might want to give it a height request or you can use a style or whatever to you know implicitly do that on all the empty ad views i haven't need that height request so it just worked for me out of the box the things that i did need to do is set the add id ads id excuse me and this is another id that you need to use so i'll just copy this from somewhere offscreen here again and this is going to be your kind of banner id so remember that i said here we have that forward slash that we want to distinguish our advertisement id and the application id it will become clear near the end whenever i go into the admob portal and show you so but this will make clear what ad we're actually going to show here so and actually that is all we need to do i can just run this thing now and we should see our first add banner pop up it will have test over it because you know these are test ids like i said provided by google just to see how it fits in your layout and if the code is all initialized properly but that is perfectly to used for demos and also to to actually test your things because you know then apple will know that you're not trying to game the system and make more revenue for yourself so you can see the app is running and you can see our banner is coming up right here so that is pretty cool with just a few lines of code boom we have our first and a banner up here and i think you can make that height request bigger when you're maybe on a tablet or something else you can also you know make it a little bit bigger and it will show you a little bit bigger ads as well it will detect how much space it has and show the right ads for you so that is all picked up automatically now there's a couple of options that you can also set on the shared instance so you can set this per banner or on the share thing but i think you know comply to family policies to be very honest i'm not entirely sure but this all has to do with gdpr and local laws and also like personalized ads so this will go out and collect all kinds of data about your user so make sure that you ask permission for your users to be able to do this or look into the laws that where you're releasing your app if this is even allowed or not i'm just here for the technical implementation i'm not going to tell you and and research for you how that all works please do that for yourself and make sure that you set these things right because this is important um this is people's privacy which is very important and you know whenever you mess this up then people might shame you for it and honestly install your app and you know then you will get bad reviews and it will be a downward spiral so please look into that like i said you can set this per banner but you can also set it on the shared instance so you know that all the advertisements that you're showing in your app will adhere to that so that is a quick note on that now the other thing i want to show you because this is just you know showing banners and stuff but there is some other cool stuff in here as well so i'm going to add a couple of buttons here and i'm going to say show video so that's cool that sounds promising and i'm going to do click so i'm going to add a new handler and i'm going to copy that and i'm going to also say interstitial i think it's called which is i don't know what the name actually is but um it is a certain type of advertisement so that is pretty cool where you can show like full screen videos and full screen interstitial so i think that's just showing a banner full screen basically and i'm now going to do that with a button click but of course you can do that with in any place in your application basically so i'm going to again stop running right here for a little bit and go to our code behind of the main page right here double click that and we have the button clicked and the button one click so i think this one was show video and this one was show interstitial there we go and there's there's something that you need to know about this because this works in a kind of special way you first need to load the video or the interstitial and then you can actually show it so i i haven't actually talked about all of this stuff but you have a lot of events that you can use so if we go back to our main page example here in the app view there is a lot of events so add click add close add fill to load add impression left application loaded open so there's a whole bunch of things here that you can use to detect what your user is also doing with this advertisement so that is really cool and the same is for with this button right here actually so you can access all of this with the cross mt admob that's also the thing that i just mentioned earlier where you can set all those privacy things there we go and it will add the using marktron.plugin and what we can say here is dot current so that is the current instance of this class and we can say on rewarded because it's a rewarded video and also here again you have a lot of events um but whenever it's loaded we are going to actually play it so we are going to declare this first and i'm going to say this sender and args because it can be the same as our little thing here and i'm just going to do this event in line with a lambda expression i could also make it a different thing but you know this works and then i'm going to say cross empty admob dot current dot play what is it reward video oh it's show probably show rewarded video there we go so this is i'm going to actually show the video now i need to actually load it so this is only going to be run when you know it's actually loaded so this doesn't do anything and i probably don't want to do it on this button click like this because like this it will each time add this handler to um to this button so actually let's just not do this to not give you the wrong example let's just do it here um and then whenever i do this i can say cross mt admob current dot load um rewarded video and there we go so here again you will have to specify this ad unit you can just use one of the test ids that marco has provided in his documentation you can also provide some empty rewarded ad options in here not going to go into too much detail there because you know this video is going to probably be long enough as it is so be sure to check that out you have some options but let me check if i have some test ad id right here for the video i'm just going to copy this from somewhere off screen here save that and here we go so whenever this is loaded this thing gets triggered and it will actually show it so you can also have two separate events you can solve this any way you like but this works so let's just implement the interstitial as well which is kind of like the same thing right here and let's say dot on interstitial loaded there we go and of course update this one too show interstitial and here again we can say we want to load it so i think this is kind of the same mechanism right here load interstitial and you can see like hey here you also have booleans to see if it's actually loaded and again this has a lot of events that you can you know interact with to show your user what's going on or decide how to go about this so let me get the interstitial id from right here copy and paste that in here and i think then we're ready to give this another go so let me just play it and now we have those two buttons and whenever i click those you can see it will load a video and it will load that interstitial so you have multiple ways of showing that advertisement which probably also means that you know you will be rewarded um in a different way so a video will probably be rewarded with a little bit more money than anything else so here we go here we can see this is rewarded and our video is loaded just by the click of a button it says test mode here at the top and i can just close this one with the little cross right here and the same thing for the interstitial which just you know is a bigger banner that will be shown full screen so here you have different advertisements that you can work with in your application which is pretty cool so quickly one last thing that i want to show you about all these ids because now you know how to implement this and it's up to you how to make it fit nicely into your layout and not maybe bug your users with it too much because you know you always have to find that balance between showing this to your user and getting to monetize your application but not um irritate them too much with the advertisements so let's go back to our browser for a little bit and i also have open here my google admob account you can see it's not going very well i just have one user and zero sense so but this is just a test app for ios uh whenever you create an app you have to specify the platform um but i'm not think i don't think that's really necessary i think you can use the same app id but have different advertisements or i don't know how you actually need to do that but let me know in the comments if you do know then i can learn from you because i'm not an expert in this stuff i just know how to implement code but you can go here apps you can say add app you can create a new one i'm sure you'll figure that out and whenever you do have that app i have that test app here you can go to app settings and here we have that app id that i was mentioning to you so this is the thing that you need to add to your metadata to your info.plist and your android manifest file and you can see this is the app id because of that tilled character right so the wavy thing that's that and then you can go to ad units um i already created there one uh two uh this is a banner you can create a new one and you can see that in your schedule you can make a rewarded video right here there's a couple of other ones that are not supported with this library right now but so just focus on the ones that are there and whenever you do i have this test ad unit and you can get that ad unit id and here we have that slash so this is the one that you need to actually put into your banner or your interstitial video loading or whatever so that is how the ids are connected together with this you should be able to monetize your app and implement those advertisements so there's a couple of things you need to do you need to set it up you need to implement some initialization code then you know add those banners by the way i'm doing all of this example but of course you can also do it in c sharp code like with everything that you can do example make sure that you get that privacy settings right that is something that is very important but other than that you know go out set up your admob account and i hope you can monetize your application and get back some of that love and effort that you've put in there let me know if this helped you if there's something else that you'd like to see if you have any more questions please let me know in the comments and i'll be sure to answer you and look at it other than that please just like this video subscribe to my channel and you know since talking about monetization you can join this channel as an actual member go check that out click that little join button to see what it's all about and you know i will be very very grateful if you actually do and support me with my efforts here a little bit other than that i will be seeing you for my next video keep coding
Info
Channel: Gerald Versluis
Views: 4,897
Rating: undefined out of 5
Keywords: Xamarin.Forms 101, xamarin forms admob, admob xamarin forms, Xamarin admob, xamarin admob rewarded video, xamarin google ads, Xamarin.Forms monetization, add ads to app, Xamarin Forms, xamarin forms tutorial, xamarin forms tutorial for beginners, xamarin tutorial, xamarin tutorial for beginners, xamarin forms ui, admob ios tutorial, admob android tutorial, C#, Xamarin 101, xamarin.forms, visual studio, Monetizing Your Xamarin.Forms App with AdMob
Id: Bka0T3806qo
Channel Id: undefined
Length: 22min 7sec (1327 seconds)
Published: Thu Feb 11 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.