Facebook上的Interstitial广告崩溃Mopub插件在Unity上

Ker*_*man 7 unity-game-engine ios mopub

当我检查组织者的崩溃时,我意识到Facebook插页式广告与Mopub插件崩溃了

我可以看到组织者的回溯.

我想找到真正的文件进行编辑并修复此崩溃.

这是回溯: 回溯

这就是我使用的方式

文件:AdSystem.cs

try {
    MoPub.showInterstitialAd(adUnit.key1);
}
catch(Exception e) {
}
Run Code Online (Sandbox Code Playgroud)

这是用于Mopub的Facebook非页内适配器 https://github.com/mopub/mopub-ios-sdk/tree/master/AdNetworkSupport/Facebook

文件:FacebookInterstitialCustomEvent.m

//
//  FacebookInterstitialCustomEvent.m
//  MoPub
//
//  Copyright (c) 2014 MoPub. All rights reserved.
//

#import <FBAudienceNetwork/FBAudienceNetwork.h>
#import "FacebookInterstitialCustomEvent.h"

#import "MPInstanceProvider.h"
#import "MPLogging.h"

@interface MPInstanceProvider (FacebookInterstitials)

- (FBInterstitialAd *)buildFBInterstitialAdWithPlacementID:(NSString *)placementID
                                                  delegate:(id<FBInterstitialAdDelegate>)delegate;

@end

@implementation MPInstanceProvider (FacebookInterstitials)

- (FBInterstitialAd *)buildFBInterstitialAdWithPlacementID:(NSString *)placementID
                                                  delegate:(id<FBInterstitialAdDelegate>)delegate
{
    FBInterstitialAd *interstitialAd = [[FBInterstitialAd alloc] initWithPlacementID:placementID];
    interstitialAd.delegate = delegate;
    return interstitialAd;
}

@end

@interface FacebookInterstitialCustomEvent () <FBInterstitialAdDelegate>

@property (nonatomic, strong) FBInterstitialAd *fbInterstitialAd;

@end

@implementation FacebookInterstitialCustomEvent

- (void)requestInterstitialWithCustomEventInfo:(NSDictionary *)info
{
    if (![info objectForKey:@"placement_id"]) {
        MPLogError(@"Placement ID is required for Facebook interstitial ad");
        [self.delegate interstitialCustomEvent:self didFailToLoadAdWithError:nil];
        return;
    }

    MPLogInfo(@"Requesting Facebook interstitial ad");

    self.fbInterstitialAd =
    [[MPInstanceProvider sharedProvider] buildFBInterstitialAdWithPlacementID:[info objectForKey:@"placement_id"]
                                                                     delegate:self];

    [self.fbInterstitialAd loadAd];
}

- (void)showInterstitialFromRootViewController:(UIViewController *)controller {
    if (!self.fbInterstitialAd || !self.fbInterstitialAd.isAdValid) {
        MPLogError(@"Facebook interstitial ad was not loaded");
        [self.delegate interstitialCustomEventDidExpire:self];
    } else {
        MPLogInfo(@"Facebook interstitial ad will be presented");
        [self.delegate interstitialCustomEventWillAppear:self];
        [self.fbInterstitialAd showAdFromRootViewController:controller];
        MPLogInfo(@"Facebook interstitial ad was presented");
        [self.delegate interstitialCustomEventDidAppear:self];
    }
}

- (void)dealloc
{
    _fbInterstitialAd.delegate = nil;
}

#pragma mark FBInterstitialAdDelegate methods

- (void)interstitialAdDidLoad:(FBInterstitialAd *)interstitialAd
{
    MPLogInfo(@"Facebook intersitital ad was loaded. Can present now");
    [self.delegate interstitialCustomEvent:self didLoadAd:interstitialAd];
}

- (void)interstitialAd:(FBInterstitialAd *)interstitialAd didFailWithError:(NSError *)error
{
    MPLogInfo(@"Facebook intersitital ad failed to load with error: %@", error.description);
    [self.delegate interstitialCustomEvent:self didFailToLoadAdWithError:nil];
}

- (void)interstitialAdDidClick:(FBInterstitialAd *)interstitialAd
{
    MPLogInfo(@"Facebook interstitial ad was clicked");
    [self.delegate interstitialCustomEventDidReceiveTapEvent:self];
}

- (void)interstitialAdDidClose:(FBInterstitialAd *)interstitialAd
{
    MPLogInfo(@"Facebook interstitial ad was closed");
    [self.delegate interstitialCustomEventDidDisappear:self];
}

- (void)interstitialAdWillClose:(FBInterstitialAd *)interstitialAd
{
    MPLogInfo(@"Facebook interstitial ad will close");
    [self.delegate interstitialCustomEventWillDisappear:self];
}

@end
Run Code Online (Sandbox Code Playgroud)

Sag*_*r V 0

从 Mopub 官方网站来看,

您应该预取插页式广告:

MoPub.requestInterstitialAd(interstitialAdUnit);
Run Code Online (Sandbox Code Playgroud)

在这种情况下,

MoPub.requestInterstitialAd(adUnit.key1);
Run Code Online (Sandbox Code Playgroud)

然后显示插页式广告:

MoPub.showInterstitialAd (interstitialAdUnit);
Run Code Online (Sandbox Code Playgroud)

就你而言,

MoPub.showInterstitialAd (adUnit.key1);
Run Code Online (Sandbox Code Playgroud)

所以,你的文件 AdSystem.cs 应该是

try {
    MoPub.requestInterstitialAd(adUnit.key1);
    MoPub.showInterstitialAd(adUnit.key1);
}
catch(Exception e) {
}
Run Code Online (Sandbox Code Playgroud)

这些回调处理程序也会帮助你

void onInterstitialLoaded (string adUnitId)
void onInterstitialFailed (string errorMsg)
void onInterstitialDismissed (string adUnitId)
void interstitialDidExpire (string adUnitId)
void onInterstitialShown (string adUnitId)
void onInterstitialClicked (string adUnitId)
Run Code Online (Sandbox Code Playgroud)

欲了解更多详细信息,请查看Mopub 官方文档