2012-07-03 41 views
0

我已将AdMob集成到我的应用程序中。AdMob集成

#define AdMob_ID @"a14fd99963270b2" 


-(void)viewDidLoad 
{ 
      [super viewDidLoad]; 

      GADBannerView *admob = [[GADBannerView alloc] initWithFrame:CGRectMake(0, 360, 320, 50)]; 
      admob.adUnitID = AdMob_ID; 
      admob.rootViewController=self; 
      [self.view addSubview:admob]; 

      GADRequest *req=[[GADRequest alloc] init]; 
      req.testing=YES; 
      [admob loadRequest:req]; 
} 

这是给我的是默认谷歌,

enter image description here

如果我改变AdMob_ID我的应用程序的ID,然后添加不显示。

什么是问题?

在创建AdMobID时,它要求提供iTunes连接应用程序链接。

这个链接可以在应用程序上线后获得。

在此先感谢。

回答

2

你确定你没有在测试模式? Admob为了测试目的显示该图片,好消息是您的admob集成工作。为了投放实时广告,请确保您未处于测试模式。

+0

thnks建议....我怎么知道这是在测试模式....? –

+0

如果您正在使用模拟器,默认情况下它将处于测试模式。看看[这个](http://stackoverflow.com/questions/8991254/testing-that-admob-working-before-publish) – codingNinja

0

在AdMob与您的应用程序集成中,您需要更改您的Gradle,Manifest和您希望显示广告的活动。 根据需要授予用户权限。 看看这个。

activity_main.xml中

xmlns:ads="http://schemas.android.com/apk/res-auto" 
<com.google.android.gms.ads.AdView 
    android:id="@+id/adView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_alignParentBottom="true" 
    ads:adSize="BANNER" 
    ads:adUnitId="@string/banner_ad_unit_id"> 
</com.google.android.gms.ads.AdView> 

的strings.xml

<string name="banner_ad_unit_id">ca-app-pub-your id</string> 

MainActivity.java

import com.google.android.gms.ads.AdRequest; 
import com.google.android.gms.ads.AdView; 

public class MainActivity extends ActionBarActivity { 
.......... 
AdView mAdView = (AdView) findViewById(R.id.adView); 
    AdRequest adRequest = new AdRequest.Builder().build(); 
    mAdView.loadAd(adRequest); 
} 

为了进一步参考,here is an AdMob for Android tutorial