2017-02-23 51 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文件,我們可以擺脫這種崩潰? –