【问题标题】:Facebook Interstitial Ad Crash Mopub Plugin on UnityUnity 上的 Facebook 插页式广告崩溃 Mopub 插件
【发布时间】:2017-07-14 04:41:05
【问题描述】:

当我在管理器上查看崩溃时,我意识到 Facebook 插页式广告与 Mopub 插件一起崩溃

我可以在管理器上看到回溯。

我想找到真正的文件来编辑和修复这个崩溃。

这是回溯:

这就是我使用的方式

文件:AdSystem.cs

try {
    MoPub.showInterstitialAd(adUnit.key1);
}
catch(Exception e) {
}

这是 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

【问题讨论】:

    标签: ios unity3d mopub


    【解决方案1】:

    来自 Mopub 的官方网站,

    您应该预取插页式广告:

    MoPub.requestInterstitialAd(interstitialAdUnit);
    

    在这种情况下,

    MoPub.requestInterstitialAd(adUnit.key1);
    

    然后显示插页式:

    MoPub.showInterstitialAd (interstitialAdUnit);
    

    在你的情况下,

    MoPub.showInterstitialAd (adUnit.key1);
    

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

    try {
        MoPub.requestInterstitialAd(adUnit.key1);
        MoPub.showInterstitialAd(adUnit.key1);
    }
    catch(Exception e) {
    }
    

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

    void onInterstitialLoaded (string adUnitId)
    void onInterstitialFailed (string errorMsg)
    void onInterstitialDismissed (string adUnitId)
    void interstitialDidExpire (string adUnitId)
    void onInterstitialShown (string adUnitId)
    void onInterstitialClicked (string adUnitId)
    

    更多详情请关注Mopub's Official Documentation

    【讨论】:

    • 感谢您的回复。我已经预取了插页式广告。我的代码运行良好,但某些设备崩溃了。我只想修复崩溃
    • 您能否提供 2 或 3 个示例设备名称。
    • Iphone 6s 10.2 Iphone SE 10.2 Iphone 5s 10.2.1 Iphone 6 10.2 我认为一些 facebook 广告崩溃了。如果我们使用 try catch 修复 FacebookInterstitialCustomEvent.m 文件,我们可以摆脱这个崩溃吗?
    猜你喜欢
    • 2018-06-08
    • 1970-01-01
    • 1970-01-01
    • 2017-05-30
    • 1970-01-01
    • 2018-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多