Quick HowTo?

Social Media Widgets / In-App Purchases / HTTP

Moderators: ezraanderson, scottwb

Quick HowTo?

Postby kreios » Mon Jan 20, 2014 11:26 am

Would anyone mind giving me a quick rundown on one of the monetization APIs? Possibly with some lua code?

So far I've tried TapJoy (half of those functions crashed my app), and AdColony (which is giving me the error "attempt to index global 'MOAIAdColonyIOS' (a nil value)"). And I can't find any information about iAds.

Are these supposed to work out of the box? If not, what do I need to do to get these to work. Is there a Git branch somewhere with one of these implemented?

Any information to get me on the right track is really appreciated.
kreios
 
Posts: 66
Joined: Wed Jun 12, 2013 5:50 pm

Re: Quick HowTo?

Postby ezraanderson » Mon Jan 20, 2014 11:57 am

~
btatarov & scottwb do in game advertising maybe they can chime in here.
Dead Dark: A roguelike, zombie apocalypse survival game
My Website | My Facebook | My Twitter | My Games on Itunes | My Games on Android
User avatar
ezraanderson
 
Posts: 1094
Joined: Wed Nov 21, 2012 2:24 pm
Location: Canada

Re: Quick HowTo?

Postby btatarov » Mon Jan 20, 2014 2:43 pm

@kreios:

ChartBoost for iOS should work almost out of the box (you probably need to throw the library file in your project). For Android however you need to write your own Chartboost.java.

I have working versions for ChartBoost, RevMob, Playhaven, AppFlood, HeyZap, Vungle and AdColony for both iOS and Android. Scott and me exchanged some code so he probably has most of my code as well (and I have his). No one else so far has been interested in monetizing apps through ads so I never cared to push my changes back to the main repo as it requires additional work on my side.

I'll write you a more detailed guide on how to get ChartBoost to work on iOS tomorrow and if the others think it's good for the project, I can spend some extra hours on merging the rest.
Unwind... rewind...
User avatar
btatarov
 
Posts: 206
Joined: Thu Sep 27, 2012 4:14 pm

Re: Quick HowTo?

Postby kreios » Mon Jan 20, 2014 2:54 pm

Thats awesome. Thank you so much.
kreios
 
Posts: 66
Joined: Wed Jun 12, 2013 5:50 pm

Re: Quick HowTo?

Postby btatarov » Tue Jan 21, 2014 6:32 am

Warning! This guide is only tested on the latest version from github (master branch). Some file names may be different in your build.

Asuming you are using XCode 5 here's how to implement ChartBoost for iOS:

1. Adding libraries to projects
- select MoaiSample (your main project) and go to Build Phases
- expand Link Binary With Libraries
- click on the plus sign down on the bottom to add a new library and find libmoai-ios-chartboost.a
- click on the plus sign again and select "Add Other", go to moai-dev/3rdparty/chartboostiOS-3.0.7/ and select libChartboost.a

2. Update AKU-iphone
- add this after the rest of the imports in src/moai-iphone/AKU-iphone.h
Code: Select all
  1. #import <AKU-chartboost.h>


- add this after the Playhaven initialisation in AKUIphoneInit () of src/moai-iphone/AKU-iphone.mm
Code: Select all
  1.         #ifndef DISABLE_CHARTBOOST

  2.                 AKUChartBoostInit ();

  3.         #endif



3. Test using the following lua code:
Code: Select all
  1. MOAIChartBoostIOS.init('<YOUR-APP-ID>', '<YOUR APP SIGNATURE>')

  2. MOAIChartBoostIOS.loadInterstitial()

  3.  

  4. -- somewhere else in your code, for example after completing a level

  5. if MOAIChartBoostIOS.hasCachedInterstitial() then

  6.         MOAIChartBoostIOS.showInterstitial()

  7. end



4. (optional) update to latest SDK, it basically involves adding the new SDK to 3rdparty/ and importing the new files in XCode (haven't tried that, yet).

It's weird why this hasn't been implemented in the main repository, yet given the fact that Chartboost is pretty stable with MOAI. I'll prepare a pull request for this and (maybe) add some other networks.
Unwind... rewind...
User avatar
btatarov
 
Posts: 206
Joined: Thu Sep 27, 2012 4:14 pm

Re: Quick HowTo?

Postby btatarov » Tue Jan 21, 2014 7:20 am

UPDATE: I created a pull request with all the changes including update to the latest version, android support and samples: https://github.com/moai/moai-dev/pull/821
Unwind... rewind...
User avatar
btatarov
 
Posts: 206
Joined: Thu Sep 27, 2012 4:14 pm

Re: Quick HowTo?

Postby kreios » Tue Jan 21, 2014 2:09 pm

@batarov,

Thanks heaps for that.

Our release date is Feb 23, so I think we'll likely just aim for in-app purchase and put in ChartBoost later on in an update.
But I'll definitely let you know how I go. I'm using a pretty recent version of the git repo, so I should't have too many dramas.
kreios
 
Posts: 66
Joined: Wed Jun 12, 2013 5:50 pm

Re: Quick HowTo?

Postby RobsterMan » Thu Sep 11, 2014 3:27 pm

Hi Btatarov and great work integrating Chartboost, and thanks to all the other MAOI developers out there including of course the Zipline guys.

I've just written my first app (well, Im still adding some levels but the coding is just about done) and I just need to integrate Chartboost now to get my $5000 per day (in my dreams of course, I'll probably be lucky to get 5 cents per week with what I've written but you've got to start somewhere!), but I'm having problems...


Where I'm at regarding Chartboost:

- I've up to date with the latest Android SDK, NDK, and MOAI (Moai SDK 1.5 revision 1)

- I opened a Chatboost account and added an app and an advertising campaign, and then I added the App ID and App Signature to your Chartboost Android sample project.

- I then built the Android Chartboost project with just a simple modification to use the Samsung Galaxy S3 resolution which I'm testing it on.

- when I'm debugging this app on the phone I see that it runs ok with this output:
I/MoaiLog (23654): Loading libmoai.so
I/MoaiLog (23654): MoaiActivity onCreate: activity CREATED
I/MoaiLog (23654): MoaiMoviePlayer onCreate: Initializing Movie Player
I/MoaiLog (23654): MoaiChartBoost onCreate: Initializing Chartboost
I/MoaiLog (23654): MoaiActivity onStart: activity STARTED
I/MoaiLog (23654): MoaiActivity onResume: activity RESUMED
I/MoaiLog (23654): MoaiActivity onResume: RESUMING now
D/MoaiLog (23654): Moai.java::pause( false )
I/MoaiLog (23654): ConnectivityBroadcastReceiver onReceive: Connection = CONNECTION_WIFI
I/MoaiLog (23654): MoaiActivity onWindowFocusChanged: activity FOCUS CHANGED
I/MoaiLog (23654): MoaiRenderer onSurfaceCreated: surface CREATED
I/MoaiLog (23654): MoaiRenderer onSurfaceChanged: surface CHANGED
I/MoaiLog (23654): MoaiRenderer onSurfaceCreated: Running game scripts
I/MoaiLog (23654): MoaiRenderer runScripts: Running ../init.lua script
I/MoaiLog (23654): load: running init.lua
I/MoaiLog (23654): MoaiRenderer runScripts: Running main.lua script
I/MoaiLog (23654): hello, Android!
I/MoaiLog (23654): MoaiActivity onPause: activity PAUSED
I/MoaiLog (23654): MoaiActivity onPause: PAUSING now
D/MoaiLog (23654): Moai.java::pause( true )
I/MoaiLog (23654): MoaiActivity onWindowFocusChanged: activity FOCUS CHANGED
I/MoaiLog (23654): MoaiActivity onWindowFocusChanged: activity FOCUS CHANGED
I/MoaiLog (23654): MoaiActivity onResume: activity RESUMED
I/MoaiLog (23654): MoaiActivity onResume: RESUMING now
D/MoaiLog (23654): Moai.java::pause( false )
I/MoaiLog (23654): MoaiRenderer onSurfaceCreated: surface CREATED
I/MoaiLog (23654): MoaiRenderer onSurfaceChanged: surface CHANGED
I/MoaiLog (23654): Showing ChartBoost interstitial.
I/MoaiLog (23654): MoaiActivity onPause: activity PAUSED
I/MoaiLog (23654): MoaiActivity onPause: PAUSING now
D/MoaiLog (23654): Moai.java::pause( true )
I/MoaiLog (23654): MoaiActivity onWindowFocusChanged: activity FOCUS CHANGED
I/MoaiLog (23654): MoaiActivity onResume: activity RESUMED
I/MoaiLog (23654): MoaiActivity onWindowFocusChanged: activity FOCUS CHANGED
I/MoaiLog (23654): MoaiActivity onWindowFocusChanged: RESUMING now
D/MoaiLog (23654): Moai.java::pause( false )
I/MoaiLog (23654): MoaiRenderer onSurfaceCreated: surface CREATED
I/MoaiLog (23654): MoaiRenderer onSurfaceChanged: surface CHANGED

So you see that I get the "Showing ChartBoost interstitial." message, but nothing actually appears on the phone screen. I expected a kind of acknowledgement from Chartboost to appear somewhere on the phone screen.

I also see that Chartboost acknowledges that connection has been made from this test app.

Have you any ideas why no output is showing on the phone or what I can do to progress from here? I'm stuck right now!

Thanks to anyone who can give me any help or advice.

RobsterMan
RobsterMan
 
Posts: 5
Joined: Thu Sep 11, 2014 2:59 pm

Re: Quick HowTo?

Postby ezraanderson » Thu Sep 11, 2014 5:03 pm

~
I had to update chartboost SDK to the most recent then change some source, but I use a custom android host.

MoaiChartBoost.java
Code: Select all
  1.  

  2. package com.ziplinegames.moai;

  3.  

  4. import android.app.Activity;

  5. import com.chartboost.sdk.*;

  6. import com.chartboost.sdk.Chartboost.CBAgeGateConfirmation;

  7. import com.chartboost.sdk.Model.CBError.CBClickError;

  8. import com.chartboost.sdk.Model.CBError.CBImpressionError;

  9.  

  10. class MoaiChartBoost {

  11.  

  12.         private static Activity sActivity = null;

  13.         private static MoaiChartBoost instance = null;

  14.         private static Chartboost cb;

  15.  

  16.         private static ChartboostDelegate chartBoostDelegate = new ChartboostDelegate() {

  17.  

  18.             public boolean shouldDisplayInterstitial(String location) {

  19.                 return true;

  20.             }

  21.  

  22.             @Override

  23.             public boolean shouldRequestInterstitial(String location) {

  24.                 return true;

  25.             }

  26.  

  27.             @Override

  28.             public void didCacheInterstitial(String location) {

  29.                 //MoaiLog.i ( "MoaiChartboost didCacheInterstitial: didCacheInterstitial" );

  30.             }

  31.  

  32.             @Override

  33.             public void didDismissInterstitial(String location) {

  34.                 cb.cacheInterstitial(location);

  35.             }

  36.  

  37.             @Override

  38.             public void didCloseInterstitial(String location) {

  39.                 // Know that the user has closed the interstitial

  40.             }

  41.  

  42.             @Override

  43.             public void didClickInterstitial(String location) {

  44.                 // Know that the user has clicked the interstitial

  45.             }

  46.  

  47.             @Override

  48.             public void didShowInterstitial(String location) {

  49.                 //MoaiLog.i ( "MoaiChartboost didShowInterstitial: didShowInterstitial" );

  50.             }

  51.  

  52.             @Override

  53.             public boolean shouldDisplayLoadingViewForMoreApps() {

  54.                 return true;

  55.             }

  56.  

  57.             @Override

  58.             public boolean shouldRequestMoreApps() {

  59.                 return true;

  60.             }

  61.  

  62.             @Override

  63.             public boolean shouldDisplayMoreApps() {

  64.                 return true;

  65.             }

  66.  

  67.             @Override

  68.             public void didCacheMoreApps() {

  69.                 // Know that the More-Apps page is cached and ready to display

  70.             }

  71.  

  72.             @Override

  73.             public void didDismissMoreApps() {

  74.                 // Know that the More-Apps page has been dismissed

  75.             }

  76.  

  77.             @Override

  78.             public void didCloseMoreApps() {

  79.                 // Know that the More-Apps page has been closed

  80.             }

  81.  

  82.             @Override

  83.             public void didClickMoreApps() {

  84.                 // Know that the More-Apps page has been clicked

  85.  

  86.             }

  87.  

  88.             @Override

  89.             public void didShowMoreApps() {

  90.                 // Know that the More-Apps page has been presented on the screen

  91.             }

  92.  

  93.             @Override

  94.             public boolean shouldRequestInterstitialsInFirstSession() {

  95.                 return true;

  96.             }

  97.  

  98.                 @Override

  99.                 public void didFailToLoadInterstitial(String arg0,

  100.                                 CBImpressionError arg1) {

  101.                         // TODO Auto-generated method stub

  102.                        

  103.                 }

  104.  

  105.                 @Override

  106.                 public void didFailToLoadMoreApps(CBImpressionError arg0) {

  107.                         // TODO Auto-generated method stub

  108.                        

  109.                 }

  110.  

  111.                 @Override

  112.                 public void didFailToRecordClick(String arg0, CBClickError arg1) {

  113.                         // TODO Auto-generated method stub

  114.                        

  115.                 }

  116.  

  117.                 @Override

  118.                 public boolean shouldPauseClickForConfirmation(

  119.                                 CBAgeGateConfirmation arg0) {

  120.                         // TODO Auto-generated method stub

  121.                         return false;

  122.                 }

  123.         };

  124.  

  125.         public static void onCreate ( Activity activity ) {

  126.                 MoaiLog.i ( "MoaiChartBoost onCreate: Initializing Chartboost" );

  127.                 sActivity = activity;

  128.         }

  129.  

  130.         public static void onDestroy () {

  131.                 MoaiLog.i ( "MoaiChartBoost onDestroy: Destroying Chartboost service" );

  132.                 cb.onDestroy(sActivity);

  133.         }

  134.  

  135.         public static void init(final String appId, final String appSignature) {       

  136.        

  137.        

  138.                 sActivity.runOnUiThread(new Runnable() {

  139.                     public void run() {                                

  140.                         cb = Chartboost.sharedChartboost();                                    

  141.                                 cb.onCreate(sActivity, appId, appSignature, chartBoostDelegate);                               

  142.                         cb.onStart(sActivity);

  143.                         cb.cacheInterstitial();

  144.                        

  145.                     }

  146.                 });

  147.                

  148.                        

  149.                

  150.         }

  151.  

  152.        

  153.         //*************************************************************

  154.         public static void showInterstitial(String location) {

  155.                                 sActivity.runOnUiThread(new Runnable() {

  156.                                     public void run() {

  157.                                         cb.showInterstitial();

  158.                                 }

  159.                                 });

  160.                    

  161.         }

  162.  

  163.        

  164.         //*************************************************************

  165.         public static boolean hasCachedInterstitial() {

  166.                 return cb.hasCachedInterstitial();

  167.         }

  168.  

  169.        

  170.         //*************************************************************

  171.         public static void loadInterstitial(String location) {

  172.                                 sActivity.runOnUiThread(new Runnable() {

  173.                                     public void run() {

  174.                                                 cb.cacheInterstitial();

  175.                                     }

  176.                                 });

  177.         }

  178. }

  179.  

  180.  

  181.  



Not sure if its the solution to your current issue.
Dead Dark: A roguelike, zombie apocalypse survival game
My Website | My Facebook | My Twitter | My Games on Itunes | My Games on Android
User avatar
ezraanderson
 
Posts: 1094
Joined: Wed Nov 21, 2012 2:24 pm
Location: Canada

Re: Quick HowTo?

Postby RobsterMan » Fri Sep 12, 2014 12:40 pm

Thank you very much ezraanderson for responding.

I updated to the latest chartboost SDK and used your MoaiChartBoost.java version but I got 18 compilation errors, including a few "cannot find symbol" errors, e.g. "symbol: class CBAgeGateConfirmation", and several "method does not override or implement a method from a supertype" errors. It seems that maybe Chartboost have made many software changes.

I did however modify the old MoaiChartBoost.java file to use the 3 functions "init", "showInterstitial", "loadInterstitial" from your file and it now works! I see the test popup, thankyou!

I might go back to the latest SDK at some stage and look at the java file but at the moment I'm extremely pushed for time. I just wanted to be sure I could get this working and with your very much appreciated help I have done so.

Thank you so much again and I hope you have a great weekend.

RobsterMan
RobsterMan
 
Posts: 5
Joined: Thu Sep 11, 2014 2:59 pm

Re: Quick HowTo?

Postby ezraanderson » Fri Nov 14, 2014 5:41 pm

~
anybody have the new ios chartboost integrated, I am not having much luck :(


edit: Sanitized see fix in below posts
---------------------
Errors: seems like it can't find the framework
Code: Select all
  1.  

  2. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:16:17: error: C++ requires a type specifier for all declarations

  3. typedef NS_ENUM(NSUInteger, CBFramework) {

  4.                 ^~~~~~~~~~

  5. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:16:29: error: unknown type name 'CBFramework'

  6. typedef NS_ENUM(NSUInteger, CBFramework) {

  7.                             ^

  8. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:16:42: error: function definition is not allowed here

  9. typedef NS_ENUM(NSUInteger, CBFramework) {

  10.                                          ^

  11. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:16:9: error: C++ requires a type specifier for all declarations

  12. typedef NS_ENUM(NSUInteger, CBFramework) {

  13. ~~~~~~~ ^

  14. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:33:27: error: expected ')'

  15. typedef NS_ENUM(NSUInteger, CBLoadError) {

  16.                           ^

  17. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:33:16: note: to match this '('

  18. typedef NS_ENUM(NSUInteger, CBLoadError) {

  19.                ^

  20. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:33:41: error: expected ';' after top level declarator

  21. typedef NS_ENUM(NSUInteger, CBLoadError) {

  22.                                         ^

  23.                                         ;

  24. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:62:27: error: expected ')'

  25. typedef NS_ENUM(NSUInteger, CBClickError) {

  26.                           ^

  27. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:62:16: note: to match this '('

  28. typedef NS_ENUM(NSUInteger, CBClickError) {

  29.                ^

  30. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:62:42: error: expected ';' after top level declarator

  31. typedef NS_ENUM(NSUInteger, CBClickError) {

  32.                                          ^

  33.                                          ;

  34. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:87:9: error: unknown type name 'NSString'

  35. typedef NSString * const CBLocation;

  36.         ^

  37. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:135:25: error: cannot find interface declaration for 'NSObject', superclass of 'Chartboost'

  38. @interface Chartboost : NSObject

  39. ~~~~~~~~~~~~~~~~~~~~~   ^

  40. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:153:25: error: expected a type

  41. + (void)startWithAppId:(NSString*)appId

  42.                         ^

  43. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:154:25: error: expected a type

  44.           appSignature:(NSString*)appSignature

  45.                         ^

  46. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:169:4: error: expected a type

  47. + (BOOL)hasInterstitial:(CBLocation)location;

  48.    ^

  49. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:198:4: error: expected a type

  50. + (BOOL)hasMoreApps:(CBLocation)location;

  51.    ^

  52. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:229:23: error: expected a type

  53. + (void)showMoreApps:(UIViewController *)viewController

  54.                       ^

  55. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:244:4: error: expected a type

  56. + (BOOL)hasRewardedVideo:(CBLocation)location;

  57.    ^

  58. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:274:25: error: expected a type

  59. + (void)didPassAgeGate:(BOOL)pass;

  60.                         ^

  61. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:290:4: error: expected a type

  62. + (BOOL)handleOpenURL:(NSURL *)url

  63.    ^

  64. /Volumes/pull/moai-dev/3rdparty/chartboostiOS-5.3/Chartboost.h:290:24: error: expected a type

  65. + (BOOL)handleOpenURL:(NSURL *)url

  66.  

  67.  

Last edited by ezraanderson on Sat Nov 15, 2014 1:43 pm, edited 1 time in total.
Dead Dark: A roguelike, zombie apocalypse survival game
My Website | My Facebook | My Twitter | My Games on Itunes | My Games on Android
User avatar
ezraanderson
 
Posts: 1094
Joined: Wed Nov 21, 2012 2:24 pm
Location: Canada

Re: Quick HowTo?

Postby halfnelson » Fri Nov 14, 2014 6:26 pm

if 5.2 is a framework then it works a little different
try using https://github.com/moaiforge/moai-sdk/b ... eLists.txt as a base and adjust it to work with chartboost
halfnelson
 
Posts: 710
Joined: Wed Jun 13, 2012 9:48 pm

Re: Quick HowTo?

Postby ezraanderson » Sat Nov 15, 2014 2:36 am

~
I got it figured out for 1.5 finally thanks to half nelson, I will post tomorrow with the steps.
Dead Dark: A roguelike, zombie apocalypse survival game
My Website | My Facebook | My Twitter | My Games on Itunes | My Games on Android
User avatar
ezraanderson
 
Posts: 1094
Joined: Wed Nov 21, 2012 2:24 pm
Location: Canada

Re: Quick HowTo?

Postby ezraanderson » Sat Nov 15, 2014 1:41 pm

~
So it was a really easy fix. The new version of chartboost 5> needs to import some header files

1. MOAIChartboostiOS.mm
Code: Select all
  1.  

  2. #import <Foundation/Foundation.h>

  3. #import <UIKit/UIKit.h>  

  4. #import <Chartboost.h>

  5.  




2. Then for moai 1.5 --> cmake/moai-iphone/CMakeLists.txt
Code: Select all
  1.  

  2. add_library(Chartboost STATIC IMPORTED)

  3. set_property(TARGET Chartboost PROPERTY IMPORTED_LOCATION ${MOAI_ROOT}/3rdparty/chartboostIOS-5.3/Chartboost)  

  4. if (NOT DISABLE_CHARTBOOST)    

  5.   set (LINK_LIBS ${LINK_LIBS} Chartboost)

  6. endif (NOT DISABLE_CHARTBOOST)

  7.  



3.Then drag the chartboost framwork into the ios xcode project.
4. Then upgrade the code in MOAICharboostiOS.mm
example:
Code: Select all
  1.  

  2.   [Chartboost startWithAppId:[ NSString stringWithUTF8String:identifier ]  appSignature:[NSString stringWithUTF8String:signature ]  delegate:MOAIChartBoostIOS::Get ().mDelegate];    

  3.   [Chartboost showInterstitial:CBLocationHomeScreen];

  4.  

  5.  



And all seems to work, thanks to halfnelson :)
Dead Dark: A roguelike, zombie apocalypse survival game
My Website | My Facebook | My Twitter | My Games on Itunes | My Games on Android
User avatar
ezraanderson
 
Posts: 1094
Joined: Wed Nov 21, 2012 2:24 pm
Location: Canada


Return to Advertising + Networking + IAPs

Who is online

Users browsing this forum: No registered users and 0 guests

cron

x