How to add AdMob ads to an existing Unity3d iOS game

Source: Internet
Author: User

1. Managing Libraries in Xcode (: https://github.com/)
Download the AdMob SDK.

Create a new folder in the project root folder named "Googleadmobadssdkios".

Copy all the files from the downloaded SDK (but not the plugins folder) to the new folder "Googleadmobadssdkios".

Right-click your project ("Unity-iphone"), then press "Add-files to Unity iPhone" and select the root folder of the new "Googleadmobadssdkios" project.

Open the drop-down tab under the linked binary Library build phase. The add frame uses the + button to become visible from the iOS SDK. Add Storekit,messageui and Adsupport to these two goals.

You now need to add-OBJC to other link markers! Project! (not target)

2. Add some code (: https://github.com/)
Open the "appcontroller.mm" file.

Add the following code to the last #import:
Import Com.keymob.networks.AdManager;
Import com.keymob.networks.core.*;
Import Com.keymob.sdk.core.AdTypes;
<uses-permission android:name= "Android.permission.INTERNET"/>
<uses-permission android:name= "Android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name= "Android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name= "Android.permission.READ_PHONE_STATE"/>

Add the following code below the line "UIWindow * _window;"
<uses-permission android:name= "Android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name= "Android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name= "Android.permission.RECORD_AUDIO"/>
Keymob.showbannerrelation (Keymob. Adsize.banner,keymob. adposition.bottom_center,0);
Document.addeventlistener (Keymob. Adevent.on_loaded_success, onadreceive, false);

Add lines before the following code "[_window makekeyandvisible];"
Also, replace "your ID here" and your AdMob Publisher ID
<activity android:name= "Com.jirbo.adcolony.AdColonyOverlay" android:configchanges= "keyboardhidden|orientation |screensize "Android:theme=" @android: Style/theme.translucent.notitlebar.fullscreen "/>

<activity android:name= "Com.jirbo.adcolony.AdColonyFullscreen" android:configchanges= "keyboardhidden| Orientation|screensize "Android:theme=" @android: Style/theme.black.notitlebar.fullscreen "/>

<activity android:name= "Com.jirbo.adcolony.AdColonyBrowser" android:configchanges= "keyboardhidden|orientation |screensize "Android:theme=" @android: Style/theme.black.notitlebar.fullscreen "/>

<service android:name= "Com.qq.e.comm.downloadservice" android:exported= "false"/>

<activity android:name= "com.qq.e.ads.adactivity" android:configchanges= "keyboard|keyboardhidden|orientation| ScreenSize "/>

Android:name= "Com.google.android.gms.ads.AdActivity"
Android:configchanges= "Keyboard|keyboardhidden|orientation|screenlayout|uimode|screensize|smallestscreensize" Android:theme= "@android: Style/theme.translucent"/>

-Add lines before the following code "[_window release];"
-force_load $ (srcroot)/KEYMOBSDK/PLUGINS/ADMOB/LIBADMOBADAPTER.A
-force_load $ (srcroot)/KEYMOBSDK/PLUGINS/INMOBI/LIBINMOBIADAPTER.A
[[AdManager sharedinstance] _setcontroller:self andlistener: [[Adlistener alloc] [init]];
[[AdManager sharedinstance] _configwithkeymobservice: @ "1" istesting:yes];
_adbanner = [[[Gadbannerview alloc] Initwithadsize:kgadadsizebanner Origin:origin] autorelease];
_adbanner.adunitid = @ "PUT YOUR ID here";
[_adbanner Setrootviewcontroller:controller];

3. Run, and you can change the banner style and location, or view my ads: https://github.com/

How to add AdMob ads to an existing Unity3d iOS game

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.