GoogleMobileAds SDK的异常行为 [英] Strange behavior with GoogleMobileAds sdk

查看:200
本文介绍了GoogleMobileAds SDK的异常行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将此方法放入 application(_ application:UIApplication,
didFinishLaunchingWithOptions

GADMobileAds.configure(withApplicationID: MYAPPID)

我的广告按预期显示。

但是,一旦我将 GADMobileAds.configure(withApplicationID: MYAPPID)移至位于库框架内的帮助程序方法中,并调用该辅助方法,广告将不会显示。控制台上也没有日志显示我所知道的错误。

However, as soon as I move the GADMobileAds.configure(withApplicationID: "MYAPPID") to a helper method located inside a library framework, and call that helper method instead, the ads do not show up. And there is no log in the console that indicates what's wrong as far as I can tell.

有人吗?知道为什么会这样吗?

Does anyone know why this is the case?

推荐答案

iOS的Google Admob文档


初始化Google Mobile Ads SDK

在应用启动时,按cal初始化Google Mobile Ads SDK在
application:didFinishLaunchingWithOptions:AppDelegate.m或
AppDelegate.swift中的
configureWithApplicationID:中。 Objective-CSwift AppDelegate.m

At app launch, initialize the Google Mobile Ads SDK by calling configureWithApplicationID: in the application:didFinishLaunchingWithOptions: method of AppDelegate.m or AppDelegate.swift. Objective-CSwift AppDelegate.m

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

  // Use Firebase library to configure APIs
  [FIRApp configure];
  [GADMobileAds configureWithApplicationID:@"ca-app-pub-3940256099942544~1458002511"];
  return YES;
}

在应用启动时初始化Google Mobile Ads SDK可使SDK达到
提取应用程序级别的设置并尽早执行
的配置任务。这可以帮助减少初始广告请求的延迟。
初始化需要一个应用程序ID。应用ID是在AdMob控制台中注册后为移动应用提供的唯一标识符

Initializing the Google Mobile Ads SDK at app launch allows the SDK to fetch app-level settings and perform configuration tasks as early as possible. This can help reduce latency for the initial ad request. Initialization requires an app ID. App IDs are unique identifiers given to mobile apps when they're registered in the AdMob console.

因此,恕我直言,您必须在应用程序启动时必须调用此configure函数。

So, IMHO, you must have to call this configure function on application launch.

希望有帮助!

这篇关于GoogleMobileAds SDK的异常行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆