phoboslab / Ejecta

A Fast, Open Source JavaScript, Canvas & Audio Implementation for iOS
2.81k stars 322 forks source link

[QUESTION] Chartboost integration #477

Closed rungo73 closed 9 years ago

rungo73 commented 9 years ago

I am using Chartboost sdk with Ejecta.

I can make call to Chartboost to show fullscreen interstitials by using EJBindingBase.

I need to be able to check for Chartboost delegate methods (dismiss ads, click for more etc)

How can I send back to JS(through Ejecta) from AppDelegate?

I am fluent JS but very limited OBJ -C. Any help would be much appreciated.

Many thanks.

matrixreal commented 9 years ago

i need this too ... i'm just know how to call a ad on app start but i need i'm using construct 2 (HTML5) and i wonder if i can call a ad interstitiel on game over state one question ? are you using lastest sdk ? (framework)

rungo73 commented 9 years ago

I'm am using latest SDK 5.x but not with Construct. I am using ImpactJS.

matrixreal commented 9 years ago

how you add it ? you follow the chartboost integration guide here ? https://answers.chartboost.com/hc/en-us/articles/201220095-iOS-Integration

because i'm having errors and warnings

matrixreal commented 9 years ago

because i have some warnings and errors you can see that here https://github.com/phoboslab/Ejecta/issues/474

finscn commented 9 years ago

@matrixreal , my fork has updated.

Now it supports Chartboost. http://github.com/finscn/Ejecta

use it like this:

var cb = new Ejecta.Chartboost("4f21c409cd1cb2fb7000001b", "92e2de2fd7070327bdeb54c15a5295309c6fcd2d");

cb.addEventListener("interstitialCache", function(){
    console.log("Interstitial Cached");
    cb.showInterstitial();
});
cb.addEventListener("moreAppsCache", function(){
    console.log("MoreApps Cached");
    cb.showMoreApps();
});
cb.addEventListener("videoCache", function(){
    console.log("Video Cached");
    cb.showVideo();
});

cb.cacheInterstitial();
cb.cacheMoreApps();
cb.cacheVideo();

More infomations in the source code of EJBindingChartboost.m

finscn commented 9 years ago

@phoboslab , I think a plugin/extension system (like unity store) of Ejecta is necessary . Do you have the plan to build one ?

rungo73 commented 9 years ago

This is great, thank you!

On Monday, April 13, 2015, finscn notifications@github.com wrote:

@matrixreal https://github.com/matrixreal , my fork has updated.

Now it supports Chartboost. http://github.com/finscn/Ejecta https://github.com/finscn/Ejecta

use it like this:

var cb = new Ejecta.Chartboost("4f21c409cd1cb2fb7000001b", "92e2de2fd7070327bdeb54c15a5295309c6fcd2d");

cb.addEventListener("interstitialCache", function(){ console.log("Interstitial Cached"); cb.showInterstitial(); }); cb.addEventListener("moreAppsCache", function(){ console.log("MoreApps Cached"); cb.showMoreApps(); }); cb.addEventListener("videoCache", function(){ console.log("Video Cached"); cb.showVideo(); });

cb.cacheInterstitial(); cb.cacheMoreApps(); cb.cacheVideo();

— Reply to this email directly or view it on GitHub https://github.com/phoboslab/Ejecta/issues/477#issuecomment-92214623.

finscn commented 9 years ago

@rungo73 & @matrixreal , I'm not a Chartboost user, I referenced to the Chartboost's official example.
So If you found any mistake, please tell me, thank you.

And who can tell me what's the different between

[Chartboost showRewardedVideo:CBLocationHomeScreen];

&

[Chartboost showRewardedVideo:CBLocationMainMenu];

?

Thanks

rungo73 commented 9 years ago

No probs.

Latest Chartboost SDK allows form named locations to display/cache ads.

Using locations you can set different campaign criteria depending on location.

For instance you could use CBLocationMainMenu to display video ad and CBlocationHomeScreeb to display static ad.

I believe if none are stipulated it reverts to a default location.

On Monday, April 13, 2015, finscn notifications@github.com wrote:

@rungo73 https://github.com/rungo73 & @matrixreal https://github.com/matrixreal , I'm not a Chartboost user, I referenced to the Chartboost's official example.

So If you found any mistake, please tell me, thank you.

And who can tell me what's the different between

[Chartboost showRewardedVideo:CBLocationHomeScreen];

&

[Chartboost showRewardedVideo:CBLocationMainMenu];

?

Thanks

— Reply to this email directly or view it on GitHub https://github.com/phoboslab/Ejecta/issues/477#issuecomment-92217276.

matrixreal commented 9 years ago

@finscn thanks a lot the code you write is the call ad ?

finscn commented 9 years ago

what's " the call ad " ? My english is very weak , sorry

matrixreal commented 9 years ago

every thing is working good thats magic ... i'm testing since yesterday and really its fast and no errors but i just work with construct 2 i need to control showing ads (interstitiel ads) if i put your listed code on index.js (main app code) thats work only on start of the application i just need to control it for example on end of game (on game over for example) so i'm searching how to make a plugin for construct 2 to control on what stade i show the ad) but thanks a lot you are my saver

rungo73 commented 9 years ago

put this with your chartboost ID numbers:

var cb = new Ejecta.Chartboost("4f21c409cd1cb2fb7000001b", "92e2de2fd7070327bdeb54c15a5295309c6fcd2d");

cb.cacheInterstitial();

in your init when you start your game.

Then anytime you want you want to call an ad in your code put this:

cb.showInterstitial();

Which will retrieve and then show an ad if one is not cached.

Hope this helps you.

And @finscn thank you so much for the chartboost binding. Very much appreciated. I'll send you a promo code for my game when it's finished. You can follow my app development @rungogames on twitter too.

Regards,

Tom

On Mon, Apr 13, 2015 at 9:11 PM, matrixreal notifications@github.com wrote:

every thing is working good thats magic ... i'm testing since yesterday and really its fast and no errors but i just work with construct 2 i need to control showing ads (interstitiel ads) if i put your listed code on index.js (main app code) thats work only on start of the application i just need to control it for example on end of game (on game over for example) so i'm searching how to make a plugin for construct 2 to control on what stade i show the ad) but thanks a lot you are my saver

— Reply to this email directly or view it on GitHub https://github.com/phoboslab/Ejecta/issues/477#issuecomment-92315723.

matrixreal commented 9 years ago

hi, if the autocache is enabled (by default), so we don't need to cache interstitiel or video ad and because that cache is performed after the ad display or maybe i'm wrong ? what is the meaning of cache ? thanks in advance

finscn commented 9 years ago

thanks @matrixreal , I have improved and updated my fork . Now it's easy to be used.

var cb = new Ejecta.Chartboost("4f21c409cd1cb2fb7000001b", "92e2de2fd7070327bdeb54c15a5295309c6fcd2d");

cb.autoCache = true;

cb.addEventListener("cache", function(event) {
    console.log(event.type + "----" + event.adType + "----" + event.message);
});
cb.addEventListener("display", function(event) {
    console.log(event.type + "----" + event.adType + "----" + event.message);
});
cb.addEventListener("click", function(event) {
    console.log(event.type + "----" + event.adType + "----" + event.message);
});
cb.addEventListener("close", function(event) {
    console.log(event.type + "----" + event.adType + "----" + event.message);
});
cb.addEventListener("error", function(event) {
    console.log(event.type + "----" + event.adType + "----" + event.message);
});
cb.addEventListener("rewared", function(event) {
    console.log(event.type + "----" + event.adType + "----" + event.message);
});

cc @rungo73

matrixreal commented 9 years ago

hi, before it work good but now not work!!! how to call interstitiel ? thanks in advance

finscn commented 9 years ago

@matrixreal @rungo73 , I learned Chartboost API, then I found some not logical places:

Chartboost.cacheXXX means : try to load XXX , then cached XXX Chartboost.showXXX means: if cached XXX, show XXX, else try to load XXX, when it's loaded(you can't know what time), display it.

I think cacheXXX is a bad name. and showXXX may be uncontrollable ( You can't know when XXX will be displayed)

So, I refactor my extension, changed some API and their usages.


var cb = new Ejecta.Chartboost("4f21c409cd1cb2fb7000001b", "92e2de2fd7070327bdeb54c15a5295309c6fcd2d");
// cb.autoCache = true;

cb.addEventListener("loaded", function(event) {
    console.log(event.type + "---" + event.adType + "---" + event.location + "---" + event.message);
});
cb.addEventListener("display", function(event) {
    console.log(event.type + "---" + event.adType + "---" + event.location + "---" + event.message);
});
cb.addEventListener("click", function(event) {
    console.log(event.type + "---" + event.adType + "---" + event.location + "---" + event.message);
});
cb.addEventListener("close", function(event) {
    console.log(event.type + "---" + event.adType + "---" + event.location + "---" + event.message);
});
cb.addEventListener("error", function(event) {
    console.log(event.type + "---" + event.adType + "---" + event.location + "---" + event.message);
});
cb.addEventListener("rewared", function(event) {
    console.log(event.type + "---" + event.adType + "---" + event.location + "---" + event.message);
});

// load 
cb.loadInterstitial("myLocation");
cb.loadMoreApps();

// if loaded
if (cb.hasInterstitial("myLocation")){
  cb.showInterstitial("myLocation");
}else{
   // do nothing or
}

// you can check if it be loaded in game-loop

My english is very weak , so If you can't understand me , please tell me.

matrixreal commented 9 years ago

@finscn you get reason me too i'm confused

1 - on chartboost blog they say to check cach before showing the ad then = check cache , and if cache is avalaible show ad if the cache is not avalaible then request the serveur for the ad and as they say this will "avoid wasteful network requests and prevent problematic behavior"

2- but if i just call showing ad i see on simulator that cache action is performed after showing the ad

so i don't know

the best is to performe autocache to enable (normally by default) and we just call the add (and it will be cached automatically)

i'm confusing and searching about this because of memory leak believe me after some runing of a game on ejecta and after some ads interstitiel and video ad the game crash with than error

http://stackoverflow.com/questions/26442414/libcabi-dylib-terminating-with-uncaught-exception-of-type-nsexception-lldb

more infos about cache chartboost here : https://answers.chartboost.com/hc/en-us/articles/200780249-Caching-iOS-

matrixreal commented 9 years ago

@finscn every is working good except rewarded video i still get JS ERROR: Error executing Javascript: {"line":1,"column":21} any solution please ?

and sometimes i got crash because of memory leak

finscn commented 9 years ago

@matrixreal could you show me your code & the log of "memory leak" ?

matrixreal commented 9 years ago

@finscn my code to call rewardedvideo is "cb.showRewardedVideo();" and about the memory leak it sometimes happen but i will post the log as soon as it crash

finscn commented 9 years ago

what is the first line in your js ? "{"line":1,"column":21}" is means the first line has error

matrixreal commented 9 years ago

var cb = new Ejecta.Chartboost("5504731343150f1703cb3894","e01451511bbd452127f8b81a9647478351e16ea7");

matrixreal commented 9 years ago

and the memory leak error is : Terminating with uncaught exception of type NSException?

finscn commented 9 years ago

I can't reproduce the isusee.

matrixreal commented 9 years ago

@finscn
ok but i think we have to create a memory management or something to unload unused audio or pictures and also to clear cache

and what about videorewarded call ?

rungo73 commented 9 years ago

I can't reproduce issue either. Code is running good for me. On Sat, 18 Apr 2015 at 3:51 am MATRIX.REAL notifications@github.com wrote:

@finscn https://github.com/finscn

ok but i think to have a memory management or something to unload unused audio or pictures and also to clear cache

and what about videorewarded call ?

— Reply to this email directly or view it on GitHub https://github.com/phoboslab/Ejecta/issues/477#issuecomment-94044778.

finscn commented 9 years ago

@matrixreal , it's not under my control , it's Chartboost SDK's task.

matrixreal commented 9 years ago

@finscn before you update your code the video rewarded worked good but now it told me javascript error when i call "cb.showRewardedVideo();"

finscn commented 9 years ago

I can't reproduce issue either. if you can't show me MORE your code (not only one line), I think I can't help you.

finscn commented 9 years ago

@matrixreal , this is my test , the content of index.js :

var cb = new Ejecta.Chartboost("5504731343150f1703cb3894", "e01451511bbd452127f8b81a9647478351e16ea7");

cb.loadRewardedVideo("myLocation");

var showed = false

setInterval(function() {

    var loaded = cb.hasRewardedVideo("myLocation");
    console.log("loaded: " + loaded);
    if (!showed && loaded) {
        showed = true;
        cb.showRewardedVideo("myLocation");
    }

}, 1000);

Please test it in your xcode (not add your code). If no error, it means the problem is in your code , not mine. If there is still an error , please tell me, thanks.

matrixreal commented 9 years ago

ah ok then the call is "load.XXXXx" and when it is loaded (hasrewardedvideo) then it will show it automatically ? right ?

matrixreal commented 9 years ago

its ok everything is working good

matrixreal commented 9 years ago

@finscn thanks a lot foe your assistance but i have 3 questions ; 1 - i see that in your fork there is a "webview.html" file ? whats that file exactly ? 2 - i see that you set retina resolution to false ? why ? 3 - what about the "encryptor.js" ? thanks in advance

finscn commented 9 years ago

loadXxxx won't show ad automatically. it just loads and caches ad resource.

for your 3 questions , I will answer you later. they are too complicated