2017-02-23 93 views
7

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

的崩溃,我可以看到组织者回溯。

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

这是回溯: Backtrace

这是我用

文件的方式:AdSystem.cs

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

这是Facebook的间质性适配器Mopub https://github.com/mopub/mopub-ios-sdk/tree/master/AdNetworkSupport/Facebook

File: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 

回答

0

从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

+0

谢谢你的回复。我已经预先填充插页式广告。我的代码工作正常,但一些设备崩溃。我只想修复崩溃问题 –

+0

您能提供2或3个示例设备名称吗? –

+0

Iphone 6s 10.2 Iphone SE 10.2 Iphone 5s 10.2.1 Iphone 6 10.2 我认为一些脸书广告崩溃。如果我们使用try catch修复FacebookInterstitialCustomEvent.m文件,我们可以摆脱这种崩溃? –