google admob ios接入问题

Creator 版本:2.0.8

目标平台:IOS

详细报错信息,包含调用堆栈:

2019-06-04 11:17:10.016948+0800 Game-mobile[1816:51025] Task .<2> finished with error - code: -999
2019-06-04 11:17:10.976326+0800 Game-mobile[1816:50663] Reward based video ad is received.
JS: ============== 展示激励广告 ==============
JS: ************* IOS展示激励广告 *************
2019-06-04 11:17:15.183938+0800 Game-mobile[1816:50663] the video is ready, open video
2019-06-04 11:17:15.184970+0800 Game-mobile[1816:50663] Opened reward based video ad.
2019-06-04 11:17:15.185483+0800 Game-mobile[1816:50663] +[RootViewController presentViewController:animated:completion:]: unrecognized selector sent to class 0x10fcef900
2019-06-04 11:17:15.196605+0800 Game-mobile[1816:50663] Presenting the reward based video ad threw exception: +[RootViewController presentViewController:animated:completion:]: unrecognized selector sent to class 0x10fcef900 with trace: (
0 CoreFoundation 0x00000001118b31e6 __exceptionPreprocess + 294
1 libobjc.A.dylib 0x0000000117173031 objc_exception_throw + 48
2 CoreFoundation 0x00000001119346c4 +[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x0000000111835898 forwarding + 1432
4 CoreFoundation 0x0000000111835278 CF_forwarding_prep_0 + 120
5 Game-mobile 0x000000010f39be14 GADSafePresentViewController + 306
6 Game-mobile 0x000000010f3b0e25 GAD_GADFullScreenAdViewController_x86_64_7_44_0 + 4213
7 Game-mobile 0x000000010f458a3c GADPresentFromViewControllerWithCompletionHandler + 410
8 Game-mobile 0x000000010f3d81b4 GAD_GADAdPresenter_x86_64_7_44_0 + 237
9 Game-mobile 0x000000010f4121a3 GAD_GADRewardBasedVideoAd_x86_64_7_44_0 + 4448
10 Game-mobile 0x000000010f404583 GADDispatchAsyncSafeMainQueue + 45
11 Game-mobile 0x000000010f412064 GAD_GADRewardBasedVideoAd_x86_64_7_44_0 + 4129
12 Game-mobile 0x000000010f2d8b44 +[RootViewController showVideo] + 148
13 CoreFoundation 0x0000000111836ccc invoking
+ 140
14 CoreFoundation 0x0000000111836b84 -[NSInvocation invoke] + 308
15 Game-mobile 0x000000010f673266

重现方式:必现

之前哪个版本是正常的 :

手机型号 :xcode 6s模拟器

手机浏览器 :

编辑器操作系统 :

编辑器之前是否有其它报错 :

出现概率:

额外线索:

oc相关代码:

RootViewController.mm

  • (void)viewDidLoad {
    [super viewDidLoad];

    [[GADMobileAds sharedInstance] startWithCompletionHandler:nil];
    [GADRewardBasedVideoAd sharedInstance].delegate = self;
    [[GADRewardBasedVideoAd sharedInstance] loadRequest:[GADRequest request]
    withAdUnitID:@“ca-app-pub-3940256099942544/1712485313”];
    NSLog(@“GADMobileAds init and request test”);
    }

  • (void)rewardBasedVideoAdDidReceiveAd:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
    NSLog(@“Reward based video ad is received.”);
    }

  • (void)rewardBasedVideoAdDidOpen:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
    NSLog(@“Opened reward based video ad.”);
    }

  • (void)rewardBasedVideoAdDidStartPlaying:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
    NSLog(@“Reward based video ad started playing.”);
    }

  • (void)rewardBasedVideoAdDidClose:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
    NSLog(@“Reward based video ad is closed.”);
    [[GADRewardBasedVideoAd sharedInstance] loadRequest:[GADRequest request]
    withAdUnitID:@“ca-app-pub-3940256099942544/1712485313”];
    }

  • (void)rewardBasedVideoAd:(GADRewardBasedVideoAd *)rewardBasedVideoAd
    didRewardUserWithReward:(GADAdReward *)reward {
    NSString *rewardMessage =
    [NSString stringWithFormat:@“Reward received with currency %@ , amount lf", reward.type, [reward.amount doubleValue]]; NSLog(@"@”, rewardMessage);
    // Reward the user for watching the video.
    }

  • (void)rewardBasedVideoAdWillLeaveApplication:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
    NSLog(@“Reward based video ad will leave application.”);
    }

  • (void)rewardBasedVideoAd:(GADRewardBasedVideoAd *)rewardBasedVideoAd
    didFailToLoadWithError:(NSError *)error {
    NSLog(@“Reward based video ad failed to load.”);
    }

  • (void)showVideo {
    if ([[GADRewardBasedVideoAd sharedInstance] isReady]) {
    NSLog(@“the video is ready, open video”);
    [[GADRewardBasedVideoAd sharedInstance] presentFromRootViewController:self];
    } else {
    [[[UIAlertView alloc]
    initWithTitle:@“Interstitial not ready”
    message:@"The interstitial didn’t finish " @“loading or failed to load”
    delegate:self
    cancelButtonTitle:@“Drat”
    otherButtonTitles:nil] show];
    }
    }

外部调用showVideo时,在[[GADRewardBasedVideoAd sharedInstance] presentFromRootViewController:self];处报错

在RootViewController.mm中重写+[RootViewController presentViewController:animated:completion:]函数依然报错

救救孩子吧

这样写试试

UIWindow *window = [[UIApplication sharedApplication] delegate].window;
UIViewController *viewController = [window rootViewController];
[[GADRewardBasedVideoAd sharedInstance] presentFromRootViewController:viewController];

没有报错了 但是视频没有播放出来 点了之后什么反应都没有

这个问题解决了吗?