How To Use Custom Ad Handler For Ios

Discussion in 'How Can I...?' started by mxstudios, Sep 12, 2016.

  1. mxstudios

    mxstudios Boxer

    Joined:
    Aug 30, 2016
    Messages:
    51
    Likes Received:
    13
    Hello all.
    So in addition to developing games, I have a mobile app analytics product similar to Flurry and Google. It's at http://www.mobilytics.net for reference.
    I was trying to figure out how to integrate into BuildBox and was having an issue understanding how to identify which screen, scene or UI they were on. I also want to be able to identify what their score is, and other things like coin count, etc...

    At the same time we were talking on another forum about using the iRate library to pop up the rating reminder on the game over screen. That also uses the custom ad handler, but again we could not identify the screen.

    Well I have figured it out. And there is a lot more that can be done too. We will start off simple and just identify the screen that handler was called from and not get into how to grab score or other things right now.

    Attached is a PDF that explains it. The most difficult (annoying) part, is that you need a header file that is not in the iOS project when you do the export from buildbox, but is included in the Windows Store export.
    I am NOT a c++ programmer, but have done some work with Cocos-X which is what is used with BuildBox, so I have been able to do some c++ code. It may not be the best way.

    You need the PTPScreensController.h file which can be found in the libraries folder when you build a Windows store version. Copy that file into libs/core/includes/screens folder in your iOS project folders.
    (see PDF)

    Then add this to top of AppController.mm

    #import "screens/PTPScreensController.h"

    Then replace the showCustomFullScreenAd method:
    (This example does something when Game Over screen is shown)


    -(void)showCustomFullscreenAd{
    PTPScreensController *psc =PTPScreensController::shared();
    const std::string sceneName = psc->currentScreenSceneKey().m_sString;
    const std::string screenUIName = psc->currentScreenUiKey().m_sString;​

    NSLog(@"Screen Scene Name: %s",psc->currentScreenSceneKey().m_sString.c_str());
    NSLog(@"Screen UI Name: %s",psc->currentScreenUiKey().m_sString.c_str());

    if (screenUIName == "PTPGameOverScreen"){
    // DO SOMETHING HERE
    // [[iRate sharedInstance] promptForRating];​
    } ​
    }
    The code will produce the internal UI name and internal Scene name to the console window. Use it to identify the name of the screen. They are names like PTPScreenScene 1 and PTPScreenUI 6. There are a few built in names like PTPGameOverScreen & PTPInfoScreen.

    Post any questions or email me. My email is in the PDF.

    Greg
     

    Attached Files:

    smmsud and Christoph like this.
  2. smmsud

    smmsud Boxer

    Joined:
    Jan 16, 2016
    Messages:
    88
    Likes Received:
    27
    Why my file structre is different? Screen Shot 2016-09-13 at 1.57.55 PM.png
     
  3. mxstudios

    mxstudios Boxer

    Joined:
    Aug 30, 2016
    Messages:
    51
    Likes Received:
    13
    BuildBox 2?

    Look on hard drive. Not in XCode.
     
  4. JoeWilson

    JoeWilson Avid Boxer

    Joined:
    Oct 8, 2015
    Messages:
    171
    Likes Received:
    65
    Greg (@mxstudios)! Fantastic idea and product with http://www.mobilytics.net. Using your own server to collect analytics data is very cool... going to download it and check it (as soon as I have some free time - lol ) --

    So but the sounds of it, I can load this on my shared host and configure a mySQL database and be good to go?

    thanks!
     

Share This Page