Heyzap Mediation Sdk 9 - Ios [tutorial]

Discussion in 'Advertising' started by Christoph, May 9, 2016.

  1. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    IMPORTANT:
    This tutorial is for SDK 9 (which is not synced with Fyber servers yet). It is recommended by Heyzap to use SDK 9 until SDK 10 is more stable. BUT you have to use for now Buildbox 2.2.7 or earlier. SDK 9 won't work with Buildbox 2.2.8. For 2.2.8 use the SDK 10 by following this tutorial instead!

    I saw a lot of people have problems setting up Heyzap Mediation. Since I just set it up for my own game, I thought it would be nice to share with all of you how to do it. If you have any additional steps or thoughts I didn't consider, please let me know and I'll add it to it. Thanks to @Aaron F and @Jayson for the help in other threads of this forum.

    If you want to implement Heyzap Mediation into an Android game don't post your questions here please. I made a separate tutorial in this thread. This tutorial is for iOS only!

    [​IMG]
    MEDIATION SETUP FOR IOS - PART 1
    The unofficial Buildbox Tutorial

    HEYZAP ACCOUNT AND SETTING UP YOUR APP
    1. First of all, you need to register for an account on https://www.heyzap.com/register
    2. Then go to your "Dashboard" and choose "All apps" and "+ Claim an App" at the top of the left side panel
    1.png

    3. Click on iOS and add your app (if it is not yet in the App Store, click on adding manually) 2.png
    To get your Bundle ID go to https://itunesconnect.apple.com, Select "My Apps" and then choose your app. The ID is in the current window under General Information.


    BUILDBOX SETUP
    1. Go to https://developers.heyzap.com/docs/buildbox and follow the 3 steps of “Integrating Heyzap in your Buildboxgame"


    HEYZAP 3rd PARTY AD NETWORK SETUP

    1. Go to your Heyzap Dashboard Integration Wizard (https://developers.heyzap.com/integration_wizard)
    (if you have already set up your 3rd party Ad Networks skip to step 6)

    2. Select the Ad Networks you want to set up and click on “Continue" 3.png

    3. Choose your App and click on “Continue"
    4.png

    4. Add all your credentials from your 3rd party Ad Networks and click each time on “Continue”(you need to register for each Ad Network and setup your app individually before you’ll get all the information needed)

    5. After adding all your credentials - and as a final step - choose “iOS" in the "SDK Integration” tab. Then skip step 6 and go directly to step 7

    5.png

    6. Go to iOS SDK/Setup and Requirements (https://developers.heyzap.com/docs/ios_sdk_setup_and_requirements) and choose your already setup Ad Networks manually
    6A.png

    7. Download the latest Heyzap SDK beta (step 2), don’t install/add it yet
    6.png

    8.Download all 3rd-party SDKs (step 4), don’t install/add them yet. Don’t close the page either as we still are going to need it
    7.png

    9. From your download folder on your Computer, select all downloaded zip files and drag and drop them to a new folder called "Heyzap SDKs”. Do yourself a favor and back it up somewhere
    8.png
    10. Uncompress all zipped SDKs and copy all files to another new folder called “Heyzap Bundle” (note that from your "heyzap-ads-sdk-x.x.x" folder, you only need to copy the "HeyzapAds.framework" from the "iOS-sdk” folder)
    9.png
     
    Last edited: Mar 27, 2017
  2. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    MEDIATION SETUP FOR IOS - PART 2
    The unofficial Buildbox Tutorial

    XCODE SETUP

    Note: For Buildbox 1.3.6 and above (including Buildbox 2) use the latest Xcode 7 to avoid errors.

    1.Open Xcode and drag your exported ios folder into the app

    2.Click on the small arrow on the left side of your “PTPlayer” project to expand the content and do the same for your “Frameworks” folder
    10.png

    3. Copy all files from your “HeyzapBundle” folder into the “Frameworks” folder. A pop-up window opens with options for adding new files. Tick "Copy items if needed" and confirm by clicking on the "Finish" button.
    11.png

    4. Now expand in the same way PTPlayer/ios/libs/ and select the AppController.mm
    12.png

    5. Go back to the “Setup and Requirements” tab from your Heyzap account and scroll to
    Step 6 of the document. Copy the huge list of "@importxxxxx;…” (see example screenshot, but don't copy it from here because it will change depending on the ad networks you have chosen earlier)
    13.png

    6. Then go back to Xcode and paste it just beneath the last line of #import (probably #import "models/PTModelController.h”) in your AppController.mm file.
    14.png

    Delete all double entries you may have (no idea why Heyzap does this)

    7. The next step is a little bit tricky. Change each @import to #import and each following element to its file path structure.

    Example: "@import AVFoundation;" changes to: "#import <AVFoundation/AVFoundation.h>”
    It’s always the name followed by a diagonal line, the name again, dot and the letter “h"
    15.png

    Note:
    The only one that is different is #import <CoreTelephony/CoreTelephonyDefines.h>
    Anyway, as you write the file name, Xcode makes you a suggestion and you can select the file with a double click. This way you won’t make any mistakes. See screenshot:
    16.png


    8. In the same AppController.mm file scroll down just a little bit and look for:
    Code:
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
    9. Position your mouse cursor just after the { sign and hit enter. Then copy/paste this code:
    Code:
    // Your Heyzap Publisher ID:
    [HeyzapAds startWithPublisherID: @"00xx4x99885xx62215880xxx3xxx5x1x"];
    17.png

    11. Go again to your web browser and open in a NEW tab https://developers.heyzap.com/account. Copy your PublisherID and replace the number between the quotation mark (from the previous step) with your own

    12. Then select your PTPlayer project again on the left side and go to the “General” tab
    First, change “Deployment Target” to 7.0 And then make sure “Requires full screen” is checked
    18.png

    14. Scroll down to “Linked Frameworks and Libraries” and click at the bottom on the + icon
    19.png
     
    Last edited: Jul 30, 2016
    Formuzal, Blaze, reegannaidoo and 2 others like this.
  3. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    MEDIATION SETUP FOR IOS - PART 3
    The unofficial Buildbox Tutorial

    15. Go back to the “Setup and Requirements” tab from your Heyzap account. Just after the huge list of the @import codes you’ll find a list of the libraries you need to add. In my case for example “libsqlite3.tbd” and "libxml2.tbd".

    20.png


    Write the name of the library in the search field of the pop up window in Xcode you just opened before, select the library and click on “Add”. Repeat the same for every library you need to add (The amount of libraries depend on the Ad Network you've chosen).
    21.png

    IMPORTANT NOTE:
    if you use Vungle you need to add additionally the following frameworks in the same manner you just added the libraries:
    WebKit.framework
    AdSupport.framework

    16. Now change from the “General” tab to the “Build Settings” tab and write in the search field: “Other Linker Flags”. Make sure "-ObjC" is already part of its content. If not, double click on the content, click on the + icon and add it manually

    22.png

    17. This is the last step and it seems BB2 has this already enabled too. so you don't have to change anything. We just make sure it's there:
    In Finder go to your project folder and look for the “PTPlayer-Info.plist” file. Open it with the app “TextEdit” (right click on the file, then choose Open With/Other… and choose TextEdit).
    23.png

    Look at the sixth line. If it says:
    Code:
     <key>NSAppTransportSecurity</key>
      <dict>
      <key>NSAllowsArbitraryLoads</key>
      <true/>
      </dict>
    ... then all is good. If it's not there, paste this exact code right after the first <dict>, save and close.

    18. This step is not necessary but to have a clean setup we will do it anyway. If you don't have any warnings in Xcode (the yellow exclamation mark sign) ignore it completely! But if you have, most probably they are:
    A) wantsFullScreenLayout warning which looks like that:

    Screen Shot 2016-06-26 at 4.08.38 PM.png

    Double click on it and it will take you to the problem in the AppController.mm file. Delete the line "viewController.wantsFullScreenLayout = YES;"
    2.png
    The warning will go away!

    B) No 'assign' and default property warnings which looks like that:
    3.png

    Double click on the first one and it will take you to the problem in the HZDemographics.h file. Change the line to (nonatomic,strong)
    [​IMG]

    Now run the game on the simulator or your device and the errors will go away too.


    That’s it! You just set up Heyzap Mediation for your game.
    Congratulations!


    ADDITIONAL SETTINGS
    One last thing to consider is to check and adjust the publisher settings in your Heyzap Dashboard. Select your app on the top left corner and go the the "Publisher Settings" tab.

    24.png

    Here you adjust how the interstitials behave.

    Verify if everything works as it should:
    In the tab "Mediation Status" (https://developers.heyzap.com/dashboard/mediation_status) you'll see if your Ad Networks are set up correctly (green).


    TEST YOUR 3rd-PARTY INTEGRATIONS
    The mediation SDK comes with a Mediation Test Suite that you can use to test each of the networks you've chosen:

    [​IMG]

    The first screen lets you pick a network. Once you choose a network, you'll see if:
    1. The network is installed correctly.
    2. The network has valid credentials on your dashboard.
    3. The network is enabled on your dashboard.
    From here, you can select a type of ad (Interstitial, Video, Incentivized, or Banner), fetch that ad, and then display it.

    To use the Mediation Test Suite follow these steps:
    1. Add temporarily this code just beneath the Heyzap Publisher ID you put in the AppController.mm file (step 9 of the tutorial)
    Code:
    // Create UIWindow
    // Set rootViewController
    [HeyzapAds presentMediationDebugViewController];
    25.png

    Then start your game on your device or on the simulator and the Heyzap debug mode will start.

    IMPORTANT: This code should be used for testing purpose and is for temporary use only. Once everything is working as it should, delete the code again and export a new build of your Game. Do NOT upload any build with the code enabled to the Apple App Store!!! It will get rejected.
     
    Last edited: Jun 26, 2016
  4. heathclose

    heathclose Miniboss Boxer

    Joined:
    Jan 28, 2016
    Messages:
    1,810
    Likes Received:
    1,025
    Awesome stuff thank you for this
     
  5. trygii

    trygii Avid Boxer

    Joined:
    Oct 14, 2015
    Messages:
    307
    Likes Received:
    72
    I have trouble setting up Unity. In Heyzap it says ''UnityAds response failed - API Failing''
    My game is not live in the app store, could this be the reason? I'm pretty sure that I entered the correct IDs etc.

    Will you put out a tut for this?
     
  6. Arsmen Studio

    Arsmen Studio Avid Boxer

    Joined:
    Dec 6, 2015
    Messages:
    454
    Likes Received:
    170
  7. onetap

    onetap Avid Boxer

    Joined:
    Oct 14, 2015
    Messages:
    122
    Likes Received:
    34
    I get this error when trying to run on a device:
    linker command failed with exit code 1 (use -v to see invocation)
     
  8. Arsmen Studio

    Arsmen Studio Avid Boxer

    Joined:
    Dec 6, 2015
    Messages:
    454
    Likes Received:
    170
  9. sysads

    sysads Serious Boxer

    Joined:
    Oct 8, 2015
    Messages:
    885
    Likes Received:
    353
    if you are using xcode, run it using simulator and see if you have same error and if so check the log for root cause.
     
  10. Arsmen Studio

    Arsmen Studio Avid Boxer

    Joined:
    Dec 6, 2015
    Messages:
    454
    Likes Received:
    170
    xcode yes , but why file not found.... in fact it didn't show the sugestion for fbaudience.. @sysads
     
  11. onetap

    onetap Avid Boxer

    Joined:
    Oct 14, 2015
    Messages:
    122
    Likes Received:
    34
    ld: 555 duplicate symbols for architecture arm64
     
  12. sysads

    sysads Serious Boxer

    Joined:
    Oct 8, 2015
    Messages:
    885
    Likes Received:
    353
    Hi, sorry I was responding to @onetap post. I need to look at yours later.
     
  13. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    @arsidalijaj: it seems you didn't add the FBAudienceNetwork.framework. I can reproduce the error when I delete it.
    @onetap: I suggest you go through the steps again from the beginning. What version of Buildbox are you using?
     
  14. onetap

    onetap Avid Boxer

    Joined:
    Oct 14, 2015
    Messages:
    122
    Likes Received:
    34
    2.0.1 and it worked but only when I didn't include a part of the Applovin sdk, could this be because Buildbox includes it already ?
     
  15. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    Did you set up other Ad Networks in Buildbox? I suggest to leave everything clean and put only the Heyzap ID. Also, in the different menus only enable Heyzap. This way there is no possibility that some code can interfere. Otherwise I really don't know what your error means. lol
     
    onetap likes this.
  16. onetap

    onetap Avid Boxer

    Joined:
    Oct 14, 2015
    Messages:
    122
    Likes Received:
    34
    I set up admob id and applovin and heyzap in Buildbox.
     
  17. Arsmen Studio

    Arsmen Studio Avid Boxer

    Joined:
    Dec 6, 2015
    Messages:
    454
    Likes Received:
    170
    @Christoph i added the FBAudienceNetwork.framework but nothing... than i deleted and re-added but still that prob. so now i am trying without facebook and other things. only heyzap unity and chartboost.
     
  18. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    Did you put FBAudienceNetwork also in Buildbox? I have had errors when using the same Network in Buildbox and Heyzap. That's why I said it is best to keep only Heyzap in Buildbox, nothing more. Which actually also makes a lot of sense. You don't want other ad networks when you already have Heyzap Mediation setup.

    The interesting thing is, I can reproduce your problem @arsidalijaj just by deleting the FBAudienceNetwork and the error appears exactly like in your screenshot. And well, the error also explains what the problem is: the file is not found. Did you tick "Copy items if needed" when copying the frameworks to Xcode?
     
    Arsmen Studio likes this.
  19. trygii

    trygii Avid Boxer

    Joined:
    Oct 14, 2015
    Messages:
    307
    Likes Received:
    72
  20. bmsingha

    bmsingha Serious Boxer

    Joined:
    Feb 17, 2016
    Messages:
    517
    Likes Received:
    198
    Thanks @Christoph really amazing smart tutorial, am was the one whos faced no of issues several times but no perfect response, you did. Thanks a lot again
     
    Christoph likes this.

Share This Page