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

Unity3d : How to integrate AdMob - Interstitial 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]
Unity project: http://sh.st/PCLxx
Visual Studio 2013 project: http://sh.st/PCLTP

Pre-require:
- VMware Fusion (For Mac)
- Visual Studio 2013 or Above (For Windows)
- 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 UnityAdMobWP8.Resources; // [yourNamespace].Resources;
using System.Diagnostics; // For print debugging


2. Create variable for InterstitialAd, AdRequest, AdView, AdUnitID. You still need AdView although you not use Banner because of AdView use to represent Ads overlay on screen.


3. Under constructor "MainPage()" add many lines of code for implement AdMob type Interstitial and AdView for display 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), Please make sure your WP connect to Windows 10 by goto Run > All apps > Windows Phone SDK 8.0/8.1 > Windows Phone Developer Registration


2. Click [>] "Green Arrow" icon and on the right side leave 3 fields as [ Device ][ Debug ][ ARM ].
[ Device ][ Debug ][ ARM ]. << For print ads debug log in console
[ Device ][ Master ][ ARM ]. << For publish to store
[ Device ][ Release ][ ARM ].  << For test ads without log in console


3. If anything goes well you should see unity logo when app launch then Ads Interstitial will appear.



[ Free source code]
Unity project: http://sh.st/PCLxx
Visual Studio 2013 project: http://sh.st/PCLTP

It's work. ;)

Comments

  1. banner ads showing interstials ids aded eror eror not showin banner and interstials :S Please admob and banner ad makeit.thanks.

    ReplyDelete
    Replies
    1. I updated about Interstitial Admob for every step by step, Please check.

      Delete
  2. Want to show interstitial ad when my game is over. Kindly help.

    ReplyDelete
    Replies
    1. You need to call Ads event from your C# in Unity to C# in Visual Studio through module. This is the way how to do that.
      http://gamedevtodied.blogspot.com/2015/08/unity3d-how-to-control-show-and-hide.html

      By this trick, you can call and control ads anywhere from your C# in Unity.

      Delete
  3. Interstitial ads shows only on emulator but not on the actual device

    ReplyDelete
    Replies
    1. My Sample test on actual device only with Lumia 535 Dual Sim.
      From my experience it's have problem on wifi connection.
      Please check your logging in Visual Studio, it's told you any issue on your device.

      Delete
  4. Hi
    thank you...

    i am tried its working perfectly but add show only game start time.

    i Want control add . example: player died game level restart . i want every restart time show add
    it is possible how ? help me....

    ReplyDelete
    Replies
    1. Try this if you want to control ads show or hide by user interaction such as click button.
      http://gamedevtodied.blogspot.com/2015/08/unity3d-how-to-control-show-and-hide.html

      Delete

Post a Comment