找不到名为MPGoogleAdMobBannerCustomEvent的自定义事件类

3

我在将AdMob SDK集成到MoPub(在Fabric中)时遇到了困难。我通过fabric安装程序安装了MoPub。我正在使用iOS和Swift,XCode版本为7.3.1(7D1014),基本SDK iOS 9.3,项目部署目标iOS 8.0。

我能够在我的应用程序中显示MoPub测试广告,但是当通过MoPub显示AdMob广告时,我会得到运行时错误。

我找不到如何在使用Fabric MoPub安装程序时集成AdMob SDK的详细说明。只有在使用独立的MoPub SDK时添加第三方库的说明。我想保留Fabric MoPub框架。

在我让MoPub测试广告正常工作后,我按照以下步骤操作:

  1. I added the GoogleAdMobCustomEvent.framework into the project, that came in the mopub-ios-custom-events.zip archive (found in https://dev.twitter.com/mopub/ios/mediation-fabric)

  2. I added the GoogleMobileAds.framework (latest version from Google: v7.8.1) to the project.

  3. In the MoPub dashboard, I created a new Order, with one Line Item and 2 ad units (banner and leaderboard) with the AdMob network.

  4. When I run the project I get the following error:

    2016-05-28 12:03:57.662 moPubTest[43756:2148130] MOPUB: Banner view (*adunit id*) loading ad with MoPub server URL: *MoPub server URL*
    2016-05-28 12:04:00.909 moPubTest[43756:2148130] MOPUB: Could not find custom event class named MPGoogleAdMobBannerCustomEvent
    2016-05-28 12:04:00.910 moPubTest[43756:2148130] MOPUB: Banner ad view is fetching ad network type: admob_native
    2016-05-28 12:04:00.910 moPubTest[43756:2148130] MOPUB: Banner view (*adunit id*) loading ad with MoPub server URL: *MoPub server URL*
    2016-05-28 12:04:00.954 moPubTest[43756:2148130] MOPUB: Banner ad view is fetching ad network type: clear
    2016-05-28 12:04:00.954 moPubTest[43756:2148130] MOPUB: No ads found for ad unit: *adunit id*
    2016-05-28 12:04:02.365 moPubTest[43756:2148130] MOPUB: Banner view (*adunit id*) failed. Error: Error Domain=com.mopub.iossdk Code=0 "The operation couldn’t be completed. (com.mopub.iossdk error 0.)"
    
看起来我漏了一步。我猜问题出在将MoPub提供的GoogleAdMobCustomEvent.framework(它是用Objective-C编写的,包含MPGoogleAdMobBannerCustomEvent头文件)集成到我的Swift项目中时。
我尝试过通过拖放和添加文件(选择复制文件选项),添加框架和头文件搜索路径,添加桥接头文件,更改框架头文件内部的路径等方式向项目中添加框架。在上述所有方法中,项目都可以编译通过,但在运行时仍然会收到错误消息: Could not find custom event class named MPGoogleAdMobBannerCustomEvent 有人知道可能出了什么问题吗?
谢谢!
更新: 我成功地使用CocoaPods将Fabric和MoPub框架安装到项目中,而不是使用Fabric应用程序。
  1. Installed Fabric and Mopub via CocoaPods https://fabric.io/kits/ios/mopub/install

  2. Instead of adding the GoogleAdMobCustomEvent.framework, I added the following Objective-C files manually to the project:

    MPGoogleAdMobBannerCustomEvent.h
    MPGoogleAdMobBannerCustomEvent.m
    MPGoogleAdMobInterstitialCustomEvent.h
    MPGoogleAdMobInterstitialCustomEvent.m

    These 4 files can be found in the AdNetworkSupport folder of the ios mopub SDK git repo

  3. Created a bridging header file with the following content:

    #import <mopub_ios_sdk/MoPub-Bridging-Header.h>
    #import <GoogleMobileAds/GoogleMobileAds.h>
    
  4. I added the GoogleMobileAds.framework (latest version from Google: v7.8.1) to the project.

  5. Added the path to the location of GoogleMobileAds.framework/Headers in the Targets' "Search Paths" -> "Framework Search Path"

理论上,您也可以通过CocoaPods安装MoPub的自定义事件,但由于一个错误,目前不可能实现。(请参见https://stackoverflow.com/a/36830967/6394927

希望这能帮助未来的某个人。

1个回答

0

我知道这是一个非常老的问题,但我现在正处于这种情况。 我已经使用Cocoapods进行了集成,但仍然遇到了这个问题。

你需要做的事情(在moPub文档中相当难以找到)是将你正在使用的广告中介添加到Podfile中。你可以在这里找到它 https://developers.mopub.com/publishers/mediation/integrate/

在我的情况下,我必须添加AdMob,所以我只需要将以下内容添加到Podfile中即可使其工作:

pod 'mopub-ios-sdk'
pod 'MoPub-AdMob-Adapters', '7.57.0.0'

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接