Unity3d : How to integrate AdMob - Banner for Windows Phone 8 (Not Unity-Plugin)

Unity3d : How to integrate AdMob - Banner for Windows Phone 8 (Not Unity-Plugin)

Test on:
- Mac OSX Yosemite
- MS Lumia 535 Dual Sim
- Windows 10 Preview
- Unity3d 32-bit 5.1.0f3 (For Windows)

[ Free source code ]
Unity3d project: http://sh.st/PZHtq
Visual Studio 2013 project: http://sh.st/PZHdn

Pre-require:
- VMware Fusion (For Mac)
- Visual Studio Community 2015 or Above (For Windows)
https://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx
- Windows Phone SDK (For Windows)
- Unity3d 32-bit/64-bit 5.1.0f3 (For Windows)
- Authenticator (For Windows Phone)
- AdMob (For Windows Phone 8) - download: https://developers.google.com/mobile-ads-sdk/download

*This tutorial for advance user that's already has all pre-require software installed properly. If you were not Mac User just focus ONLY windows software and windows os.

**Not included how to Visual Studio and Windows Phone SDK installation and setup

[Build for Windows Phone 8]
1. Open your project on windows os then goto File > Build Settings...


2. Choose "Windows Phone 8" and click "Build"


3. I'm create folder named "ExportWP8" and click "Select Folder"


4. waiting until build process successful.



5. Open "ExportWP8" folder, the .sln file ready for use in Visual Studio.



[Integrate AdMob]

1. Download AdMob (For Windows Phone 8) - here: https://developers.google.com/mobile-ads-sdk/download then extract and you should have be like this.


2. from [Build for Windows Phone 8] step 5. Open yourProjectName.sln with Visual Studio.

3. Under "Solution Explorer", right-click and choose "Add References..."


4. Click "Extension" and choose "Browse..."


5. Goto "GoogleMobileAdsSdkWindowsPhone8-6.5.13/lib/windowsphone8/" and select "GoogleAds.dll" then click "Add"


6. You should see result as below and then click "OK".


7. Now your project has GoogleAds integrated.



[AdMob Implement]
1. Next step, you need to modify and implement AdMob in your project, Open "MainPage.xaml.cs" and add 3 lines of code as below image.

using GoogleAds;
using UnityWP8AdMobBanner.Resources; // [your namespace].Resources;
using System.Diagnostics; // for print debug log in console


2. Create variable for AdRequest and AdView, this AdView for banner object that contain adUnitID and Format.


3. Under constructor "MainPage()" add many lines of code for implement AdMob type Banner as below image.


4. Add AdMob Listener for any event like below.


5. Under "Properties" section open "WMAppManifest.xml", click "Capabilities" and check all of list like this.
[/] ID_CAP_IDENTITY_DEVICE
[/] ID_CAP_IDENTITY_USER
[/] ID_CAP_MEDIALIB_AUDIO
[/] ID_CAP_MEDIALIB_PHOTO
[/] ID_CAP_MEDIALIB_PLAYBACK
[/] ID_CAP_SENSORS
[/] ID_CAP_WEBBROWSERCOMPONENT


6. Build your project by choose menu "BUILD > Build Solution".


7. Your result should be "1 succeeded" as below image, You're completed implement AdMob.



[AdMob Testing]
1. Connect your "WindowsPhone" to Windows Desktop / Laptop or Mac (Choose connect Windows), you must check the connection between WP and Windows 10 by goto run > All apps > Windows Phone SDK 8.0/8.1 > Windows Phone Developer Registration. If you seen like below image it's sure your phone already connected. If not and button show "retry" then try to reconnect your WP via usb again or "register" mean you need to register before test this app.


2. Click [>] "Green Arrow" icon and on the right side leave 3 fields as [ Device ][ Debug ][ ARM ]. This mode you can check log in console what happen to your app. Then you should check all 3 modes make sure your app work 100%.
[ Device ][ Debug ][ ARM ] << check app working log with this mode
[ Device ][ Master ][ ARM ] << for publish app to store
[ Device ][ Release ][ ARM ] << check app working without log

3. After app launch it's take a while to receive ads and callback to listener. Then you'll see banner ads.


[ Free source code ]
Unity3d project: http://sh.st/PZHtq
Visual Studio 2013 project: http://sh.st/PZHdn

It's work. ;)

Comments

  1. Thanks! I've been trying to figure out how to integrate admob in a Unity WP8 build for ages. Your tutorial really helped me out. Thanks again!

    ReplyDelete
  2. Can I control show/hide Admob in Unity code ?

    ReplyDelete
    Replies
    1. Try this, http://gamedevtodied.blogspot.com/2015/08/unity3d-how-to-control-show-and-hide.html

      Delete
  3. Thanks a lot :D, really help me. But, can I show interstitial ad when game over?? Sorry for my bad english XDDDDDDD

    ReplyDelete
    Replies
    1. If you've done Banner, try to modified for Interstitial Ads here - http://gamedevtodied.blogspot.com/2015/08/unity3d-how-to-integrate-admob.html

      So for control ads show or hide from Unity, try this - http://gamedevtodied.blogspot.com/2015/08/unity3d-how-to-control-show-and-hide.html

      Delete
  4. Not working if build for Windows Store (Phone 8.1). What to do?

    ReplyDelete
    Replies
    1. Yes, Admob not working for Windows Store (WP8.1) at this time, it's has an error AdView reference, so if you want to make money by adding ads just try this https://msdn.microsoft.com/en-US/library/mt313124(v=msads.30).aspx

      Delete
    2. is this still the case?

      Delete
  5. thanks man, will try this out tonight. never got admob or adpub working on my wpa.

    ReplyDelete
  6. I followed all the steps exactly. The app launches on windows phone but no banner is displayed. Why so ? I added all the lines of code exactly where you told them to.
    Also, in a previous comment you told Admob is not working now, can you please explain, it will be very helpful.

    ReplyDelete
    Replies
    1. About AdMob, when you export project from Unity for windows platform
      - Windows Store >> AdMob Not Working
      - Windows Phone 8 >> AdMob Work as My Sample Tutorial

      So, if you try from my tutorial and it's not work please send your source code only exported by platform "Windows Phone 8" from Unity. I'll check and if you want my sample ads project, I'll upload tomorrow and told you in this topics.

      Delete

Post a Comment