Ios:tutorial To Add Admob Custom Reward Video To Buildbox Games

Discussion in 'How Can I...?' started by TheGameAppStudio, Feb 14, 2019.

  1. wissemslimi974

    wissemslimi974 Boxer

    Joined:
    Nov 26, 2015
    Messages:
    67
    Likes Received:
    23
    Can you please share the method to integrate IronSource ?
     
  2. Kevin Nguyen

    Kevin Nguyen Boxer

    Joined:
    Sep 27, 2018
    Messages:
    23
    Likes Received:
    14
    Thanks for that tutorial :D. It's still working fine with latest buildbox 2 :)
     
    TheGameAppStudio likes this.
  3. belmir

    belmir Avid Boxer

    Joined:
    Jun 29, 2018
    Messages:
    129
    Likes Received:
    45
    I can not open mac os files on notepad is normal? how to comfigure the file
    what does this function with the latest beta bb 2.3.8 ?
    thank you
     
    Last edited: Dec 6, 2019
  4. dmmcmah

    dmmcmah Avid Boxer

    Joined:
    Sep 25, 2015
    Messages:
    103
    Likes Received:
    20
    I pasted your code in. It shows the ad but doesn't go back to the checkpoint. What am I missing?
     
  5. Dan Oprean

    Dan Oprean Boxer

    Joined:
    Feb 12, 2020
    Messages:
    6
    Likes Received:
    3
    Hi,

    The code is excelent. The problem is that on ios, apart from android where it is done automatically, when the rewarded runs it does not stop the background music and we have 2 sounds playing, the rewarded video sound and the background sound in the same time. Do you know how to pause the sound when the rewarded plays and resume it after it is done ? Thanks
     
  6. Dan Oprean

    Dan Oprean Boxer

    Joined:
    Feb 12, 2020
    Messages:
    6
    Likes Received:
    3
    I fixed it, if someone else is experiencing the same problem use PTAdController::shared()->setMusic(false); on rewardedBasedVideoAdDidOpen
     
    TheGameAppStudio and belmir like this.
  7. belmir

    belmir Avid Boxer

    Joined:
    Jun 29, 2018
    Messages:
    129
    Likes Received:
    45
    hi @Dan Oprean
    it works bb2.3.8 last beta 15? can you put the completed code on a file and share it thank you
     
  8. Dan Oprean

    Dan Oprean Boxer

    Joined:
    Feb 12, 2020
    Messages:
    6
    Likes Received:
    3
    Hi,

    Yes it works with buildbox but the code needs to be exported for ios and in xcode you just go to the AdIntegrator_bb.mm and chage the whole code there with this one :

    Note: Code is also adopted to not give the reward if the user does not watch the whole ad.





    #import "AdIntegrator.h"

    #import <GoogleMobileAds/GoogleMobileAds.h>

    #include "ads/PTAdController.h"

    @implementationAdIntegrator

    + (id)shared{

    static AdIntegrator* integrator = nil;

    @synchronized(self){

    if(integrator == nil){

    integrator = [[self alloc] init];

    }

    }

    return integrator;

    }

    #pragma mark Core Methods

    - (void)initAds{

    NSLog(@"[Ads] initialization");

    [GADMobileAdsconfigureWithApplicationID:mad:"YOUR_APP_ID(the ~ one)"];

    [GADRewardBasedVideoAdsharedInstance].delegate = self;

    [[GADRewardBasedVideoAdsharedInstance] loadRequest:[GADRequestrequest]

    withAdUnitID:mad:"YOUR_APP_ID(the / one)"];

    }


    - (void)rewardBasedVideoAd:(GADRewardBasedVideoAd *)rewardBasedVideoAd

    didRewardUserWithReward:(GADAdReward *)reward {

    NSString *rewardMessage =

    [NSStringstringWithFormat:mad:"Reward received with currency %@ , amount %lf",

    reward.type,

    [reward.amount doubleValue]];

    NSLog(rewardMessage);

    PTAdController::shared()->rewardedVideoDidEnd();

    }

    - (void)rewardBasedVideoAdDidReceiveAd:(GADRewardBasedVideoAd *)rewardBasedVideoAd {

    NSLog(@"Reward based video ad is received.");

    }

    - (void)rewardBasedVideoAdDidOpen:(GADRewardBasedVideoAd *)rewardBasedVideoAd {

    NSLog(@"Opened reward based video ad.");

    PTAdController::shared()->setMusic(false);

    }

    - (void)rewardBasedVideoAdDidStartPlaying:(GADRewardBasedVideoAd *)rewardBasedVideoAd {

    NSLog(@"Reward based video ad started playing.");

    }

    - (void)rewardBasedVideoAdDidCompletePlaying:(GADRewardBasedVideoAd *)rewardBasedVideoAd {

    NSLog(@"Reward based video ad has completed.");

    }

    - (void)rewardBasedVideoAdDidClose:(GADRewardBasedVideoAd *)rewardBasedVideoAd {

    NSLog(@"Reward based video ad is closed.");

    [[GADRewardBasedVideoAdsharedInstance] loadRequest:[GADRequestrequest]

    withAdUnitID:mad:"YOUR_APP_ID(the / one)"];

    }

    - (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)showBanner{

    NSLog(@"[Ads] show banner");

    }

    -(void)hideBanner{

    NSLog(@"[Ads] hide banner");

    }

    -(bool)isBannerVisible{

    return true;

    }

    -(bool)isRewardedVideoAvialable{

    return true;

    }

    -(void)showInterstitial{

    NSLog(@"[Ads] show interstitial");

    }

    -(void)showRewardedVideo{



    if ([[GADRewardBasedVideoAdsharedInstance] isReady]) {

    [[GADRewardBasedVideoAdsharedInstance] presentFromRootViewController:[UIApplicationsharedApplication].keyWindow.rootViewController];

    } else {

    NSLog(@"Ad wasn't ready");

    }

    NSLog(@"[Ads] show rewarded video");

    }

    -(void)buttonActivated:(NSString*) name{

    }

    -(bool)buttonVisible:(NSString*)name{

    return true;

    }

    #pragma mark Integration

    @end
     
  9. Dan Oprean

    Dan Oprean Boxer

    Joined:
    Feb 12, 2020
    Messages:
    6
    Likes Received:
    3
    Please check the text file as well as I was not aware that it will turn text into emojis on the forum.
     

    Attached Files:

  10. belmir

    belmir Avid Boxer

    Joined:
    Jun 29, 2018
    Messages:
    129
    Likes Received:
    45
  11. belmir

    belmir Avid Boxer

    Joined:
    Jun 29, 2018
    Messages:
    129
    Likes Received:
    45
    @Dan Oprean
    you don’t have the code for Android?
     
  12. Dan Oprean

    Dan Oprean Boxer

    Joined:
    Feb 12, 2020
    Messages:
    6
    Likes Received:
    3
    I have the code for Android as well, I will post it a little later.
     
  13. belmir

    belmir Avid Boxer

    Joined:
    Jun 29, 2018
    Messages:
    129
    Likes Received:
    45
  14. Dan Oprean

    Dan Oprean Boxer

    Joined:
    Feb 12, 2020
    Messages:
    6
    Likes Received:
    3
    belmir likes this.
  15. Shaun Guidolin

    Shaun Guidolin Boxer

    Joined:
    Jun 11, 2020
    Messages:
    5
    Likes Received:
    3
    where would I find the
    ads/PTAdController.h
    file?
     

Share This Page