diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7a4a3ea --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/Readme.md b/Readme.md index 746064d..61c4755 100644 --- a/Readme.md +++ b/Readme.md @@ -1,27 +1,43 @@ -Cordova Chartboost plugin v 0.2 +Cordova Chartboost plugin v 0.4 ============= -This plugin will allow you to run Chartboost on cordova projects. +This plugin will allow you to run Chartboost on cordova projects. +Source code of this plugin is forked from SpilGames's plugin (https://github.com/spilgames/cordova-chartboost-plugin) Usage ------- The plugin has the following calls: - +```JavaScript Chartboost.init(appID,appSignature); - +``` This will initialize Chartboost. You will find the appID and the appSignature of your app on the Chartboost dashboard once you have create an app in your account - +```JavaScript + Chartboost.cacheInterstitial(success, fail, location); +``` +This will cache an Insterstitial Ad. The parameters are the success and failure callbacks and the location of the interstitial. +```JavaScript Chartboost.showInterstitial(success, fail, location); +``` +This will show an Insterstitial Ad. The parameters are the success and failure callbacks and the location of the interstitial. + +For iOS applications also available calls for MoreApps screen and Video Ads: + +```JavaScript + Chartboost.showMoreGames(success, fail, location); + Chartboost.cacheMoreGames(success, fail, location); + Chartboost.showRewardedVideo(success, fail, location); + Chartboost.cacheRewardedVideo(success, fail, location); + Chartboost.hasRewardedVideo(success, fail, location); +``` -This will show an Insterstitial Add. The parameters are the success and failure callbacks and the location of the interstitial. The callbacks system is still not implemented. The project still need a lot of work. Right now there are the basic calls to make it work and get interstitials from Chartboost. INSTALLATION ------------- - cordova plugin add https://github.com/spilgames/cordova-chartboost-plugin + cordova plugin add https://github.com/alexportnoy/cordova-chartboost-plugin SUPPORTED PLATFORMS @@ -33,18 +49,32 @@ SUPPORTED PLATFORMS TODO ------ -- Callbacks implementation -- Video calls implementation +- Video Ads calls implementation for Android +- MoreApps calls implementation for Android CHANGELOG --------- +v0.4 (by danmorton) +- Callbacks implementation on Android +- Support for didDissmiss callback on iOS/Android +- Bugfixes + +v0.3: +First version of forked plugin: +- New versions of Chartboost SDKs +- Call to cache interstitials +- Call to cache/show MoreApps screen (iOS) +- Call to cache/show video ads (iOS) +- Implementation of callbacks system (iOS) + +v0.2: +In original plugin repo: +- Support for iOS platform + v0.1: First version of the plugin: - Call to initialize Chartboost with the appId and the appSignature - Call to show interestitials -v0.2: -Support for iOS platform - diff --git a/libs/Chartboost.framework/Versions/A/Chartboost b/libs/Chartboost.framework/Versions/A/Chartboost index 65002da..f5f9deb 100644 Binary files a/libs/Chartboost.framework/Versions/A/Chartboost and b/libs/Chartboost.framework/Versions/A/Chartboost differ diff --git a/libs/Chartboost.framework/Versions/A/Headers/CBAnalytics.h b/libs/Chartboost.framework/Versions/A/Headers/CBAnalytics.h index d612a4d..7987ad9 100644 --- a/libs/Chartboost.framework/Versions/A/Headers/CBAnalytics.h +++ b/libs/Chartboost.framework/Versions/A/Headers/CBAnalytics.h @@ -1,7 +1,7 @@ /* * CBAnalytics.h * Chartboost - * 5.0.3 + * 5.1.5 * * Copyright 2011 Chartboost. All rights reserved. */ diff --git a/libs/Chartboost.framework/Versions/A/Headers/CBInPlay.h b/libs/Chartboost.framework/Versions/A/Headers/CBInPlay.h index 25e8132..4a9ecdb 100644 --- a/libs/Chartboost.framework/Versions/A/Headers/CBInPlay.h +++ b/libs/Chartboost.framework/Versions/A/Headers/CBInPlay.h @@ -1,7 +1,7 @@ /* * CBInPlay.h * Chartboost - * 5.0.3 + * 5.1.5 * * Copyright 2011 Chartboost. All rights reserved. */ @@ -112,4 +112,14 @@ */ - (void)click; +/*! + @abstract + Clears all CBInPlay objects from the cache locations. + + @discussion This method will clear all the CBInPlay native ads from the internal cash. + This is intended to be used to either force an update for all content or reduce the + memory overhead of this feature. + */ +- (void)clearCache; + @end diff --git a/libs/Chartboost.framework/Versions/A/Headers/CBMoreAppsBadge.h b/libs/Chartboost.framework/Versions/A/Headers/CBMoreAppsBadge.h index 12b6377..797b6a9 100644 --- a/libs/Chartboost.framework/Versions/A/Headers/CBMoreAppsBadge.h +++ b/libs/Chartboost.framework/Versions/A/Headers/CBMoreAppsBadge.h @@ -1,7 +1,7 @@ /* * CBMoreAppsBadge.h * Chartboost - * 5.0.3 + * 5.1.5 * * Copyright 2011 Chartboost. All rights reserved. */ diff --git a/libs/Chartboost.framework/Versions/A/Headers/CBMoreAppsButton.h b/libs/Chartboost.framework/Versions/A/Headers/CBMoreAppsButton.h index 8a79dfc..3f90b6b 100644 --- a/libs/Chartboost.framework/Versions/A/Headers/CBMoreAppsButton.h +++ b/libs/Chartboost.framework/Versions/A/Headers/CBMoreAppsButton.h @@ -1,7 +1,7 @@ /* * CBMoreAppsButton.h * Chartboost - * 5.0.3 + * 5.1.5 * * Copyright 2011 Chartboost. All rights reserved. */ diff --git a/libs/Chartboost.framework/Versions/A/Headers/CBNewsfeed.h b/libs/Chartboost.framework/Versions/A/Headers/CBNewsfeed.h index 2bf1833..3ac23cd 100644 --- a/libs/Chartboost.framework/Versions/A/Headers/CBNewsfeed.h +++ b/libs/Chartboost.framework/Versions/A/Headers/CBNewsfeed.h @@ -1,7 +1,7 @@ /* * CBNewsfeed.h * Chartboost - * 5.0.3 + * 5.1.5 * * Copyright 2011 Chartboost. All rights reserved. */ diff --git a/libs/Chartboost.framework/Versions/A/Headers/CBNewsfeedUI.h b/libs/Chartboost.framework/Versions/A/Headers/CBNewsfeedUI.h index 9c85471..2760d95 100644 --- a/libs/Chartboost.framework/Versions/A/Headers/CBNewsfeedUI.h +++ b/libs/Chartboost.framework/Versions/A/Headers/CBNewsfeedUI.h @@ -1,7 +1,7 @@ /* * CBNewsfeedUI.h * Chartboost - * 5.0.3 + * 5.1.5 * * Copyright 2011 Chartboost. All rights reserved. */ diff --git a/libs/Chartboost.framework/Versions/A/Headers/CBStory.h b/libs/Chartboost.framework/Versions/A/Headers/CBStory.h index c6f6dfc..ddd09f3 100644 --- a/libs/Chartboost.framework/Versions/A/Headers/CBStory.h +++ b/libs/Chartboost.framework/Versions/A/Headers/CBStory.h @@ -1,7 +1,7 @@ /* * CBStory.h * Chartboost - * 5.0.3 + * 5.1.5 * * Copyright 2011 Chartboost. All rights reserved. */ diff --git a/libs/Chartboost.framework/Versions/A/Headers/Chartboost.h b/libs/Chartboost.framework/Versions/A/Headers/Chartboost.h index 9b95641..f2cd85d 100644 --- a/libs/Chartboost.framework/Versions/A/Headers/Chartboost.h +++ b/libs/Chartboost.framework/Versions/A/Headers/Chartboost.h @@ -1,7 +1,7 @@ /* * Chartboost.h * Chartboost - * 5.0.3 + * 5.1.5 * * Copyright 2011 Chartboost. All rights reserved. */ @@ -21,7 +21,19 @@ typedef NS_ENUM(NSUInteger, CBFramework) { /*! Adobe AIR. */ CBFrameworkAIR, /*! GameSalad. */ - CBFrameworkGameSalad + CBFrameworkGameSalad, + /*! Cordova. */ + CBFrameworkCordova, + /*! CocoonJS. */ + CBFrameworkCocoonJS, + /*! Cocos2d-x. */ + CBFrameworkCocos2dx, + /*! MoPub. */ + CBFrameworkMoPub, + /*! Fyber. */ + CBFrameworkFyber, + /*! Prime31Unreal. */ + CBFrameworkPrime31Unreal }; /*! @@ -70,6 +82,22 @@ typedef NS_ENUM(NSUInteger, CBClickError) { CBClickErrorInternal, }; +/*! + @typedef NS_ENUM (NSUInteger, CBStatusBarBehavior) + + @abstract + Used with setStatusBarBehavior:(CBStatusBarBehavior)statusBarBehavior calls to set how fullscreen ads should + behave with regards to the status bar. + */ +typedef NS_ENUM(NSUInteger, CBStatusBarBehavior) { + /*! Ignore status bar altogether; fullscreen ads will use the space of the status bar. */ + CBStatusBarBehaviorIgnore, + /*! Respect the status bar partially; fullscreen ads will use the space of the status bar but any user interactive buttons will not. */ + CBStatusBarBehaviorRespectButtons, + /*! Respect the status bar fully; fullscreen ads will not use the status bar space. */ + CBStatusBarBehaviorRespect +}; + /*! @typedef CBLocation @@ -154,6 +182,16 @@ extern CBLocation const CBLocationDefault; appSignature:(NSString*)appSignature delegate:(id)delegate; +/*! + @abstract + Check to see if any views are visible + + @return YES if there is any view visible + + @discussion This method can be used to check if any chartboost ad's are visible on the app. + */ ++ (BOOL)isAnyViewVisible; + /*! @abstract Determine if a locally cached interstitial exists for the given CBLocation. @@ -457,6 +495,17 @@ extern CBLocation const CBLocationDefault; */ + (BOOL)getAutoCacheAds; +/*! + @abstract + Set to control how the fullscreen ad units should interact with the status bar. (CBStatusBarBehaviorIgnore by default). + + @param statusBarBehavior The param to set if fullscreen video should respect the status bar. + + @discussion See the enum value comments for descriptions on the values and their behavior. Only use this feature if your + application has the status bar enabled. + */ ++ (void)setStatusBarBehavior:(CBStatusBarBehavior)statusBarBehavior; + @end /*! @@ -685,6 +734,17 @@ extern CBLocation const CBLocationDefault; - (void)didFailToLoadMoreApps:(CBLocation)location withError:(CBLoadError)error; +#pragma mark - Video Delegate + +/*! + @abstract + Called after videos have been successfully prefetched. + + @discussion Implement to be notified of when the prefetching process has finished successfully. + */ + +- (void)didPrefetchVideos; + #pragma mark - Rewarded Video Delegate /*! @@ -948,6 +1008,8 @@ extern CBLocation const CBLocationDefault; */ - (void)didLoadInPlay __attribute__((deprecated("As of version 4.5, use didCacheInPlay:(CBLocation)location"))); + + @end diff --git a/libs/chartboost.jar b/libs/chartboost.jar index 6108944..3a971a6 100644 Binary files a/libs/chartboost.jar and b/libs/chartboost.jar differ diff --git a/package.json b/package.json new file mode 100644 index 0000000..7c4ffdf --- /dev/null +++ b/package.json @@ -0,0 +1,39 @@ +{ + "name": "cordova-chartboost-plugin", + "version": "0.4.0", + "description": "Cordova Chartboost plugin. Forked from SpilGames's plugin.", + "cordova": { + "id": "com.portnou.cordova.plugin.chartboost", + "platforms": [ + "android", + "ios" + ] + }, + "repository": { + "type": "git", + "url": "https://github.com/alexportnoy/cordova-chartboost-plugin.git" + }, + "keywords": [ + "chartboost", + "ads", + "monetization", + "games", + "ios", + "android", + "ecosystem:cordova", + "cordova-android", + "cordova-ios" + ], + "engines": [ + { + "name": "cordova", + "version": ">=3.0.0" + } + ], + "author": "Alexander S Portnoy", + "license": "Apache 2.0", + "bugs": { + "url": "https://github.com/alexportnoy/cordova-chartboost-plugin/issues" + }, + "homepage": "https://github.com/alexportnoy/cordova-chartboost-plugin" +} diff --git a/plugin.xml b/plugin.xml index 2e00edd..97d7b8c 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,11 +1,15 @@ + id="com.portnou.cordova.plugin.chartboost" + version="0.4.0"> + Cordova Chartboost Plugin - Cordova Chartboost plugin - Spil Games + Cordova Chartboost plugin. Forked from SpilGames's plugin. + chartboost,ads,monetization,games,ios,android + https://github.com/alexportnoy/cordova-chartboost-plugin + Alexander S Portnoy + Apache 2.0 @@ -20,7 +24,7 @@ - + @@ -29,7 +33,7 @@ - + diff --git a/src/android/ChartboostPlugin.java b/src/android/ChartboostPlugin.java index f0ba197..17c2061 100644 --- a/src/android/ChartboostPlugin.java +++ b/src/android/ChartboostPlugin.java @@ -1,66 +1,400 @@ -package com.spilgames.chartboost.plugin; +package com.portnou.cordova.plugin.chartboost; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaPlugin; import org.json.JSONArray; import org.json.JSONException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.chartboost.sdk.CBLocation; import com.chartboost.sdk.Chartboost; +import com.chartboost.sdk.ChartboostDelegate; +import com.chartboost.sdk.InPlay.CBInPlay; +import com.chartboost.sdk.Libraries.CBLogging.Level; +import com.chartboost.sdk.Model.CBError.CBClickError; +import com.chartboost.sdk.Model.CBError.CBImpressionError; +import com.chartboost.sdk.Tracking.CBAnalytics; public class ChartboostPlugin extends CordovaPlugin{ - - + //tags for identifying Cordova Calls. private static final String ACTION_INI_CHARBOOST = "init"; private static final String ACTION_SHOW_INTERSTITIAL = "showInterstitial"; - + private static final String ACTION_CACHE_INTERSTITIAL = "cacheInterstitial"; + private static final String ACTION_SHOW_MOREGAMES = "showMoreGames"; + private static final String ACTION_CACHE_MOREGAMES = "cacheMoreGames"; + private static final String ACTION_SHOW_REWARDVIDEO = "showRewardedVideo"; + private static final String ACTION_CACHE_REWARDVIDEO = "cacheRewardedVideo"; + private static final String ACTION_HAS_REWARDVIDEO = "hasRewardedVideo"; + private static final String ACTION_SET_DISMISSCALLBACK = "setDidDismissInterstitialCallback"; + private ChartboostPlugin me; + private static final String TAG = "ChartboostPlugin"; + + @Override - public void onDestroy() { - Chartboost.onDestroy(cordova.getActivity()); - super.onDestroy(); + public boolean execute(String action, JSONArray args, CallbackContext callback) throws JSONException { +// android.util.Log.i(TAG, "execute called: " + action + ", args: " + args.toString()); + me = this; + final CallbackContext _callback = callback; + if (action.equals(ACTION_INI_CHARBOOST)) { + final String app_id = args.getString(0); + final String app_sig = args.getString(1); + cordova.getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + me.chartboost_init(app_id, app_sig); + } + }); + } else if (action.equals(ACTION_SHOW_INTERSTITIAL)){ + final String location = args.getString(0); + cordova.getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + me.showInterstitial(location, _callback); + } + }); + } else if (action.equals(ACTION_CACHE_INTERSTITIAL)){ + final String location = args.getString(0); + cordova.getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + me.preloadInterstitial(location, _callback); + } + }); + } else if (action.equals(ACTION_SHOW_MOREGAMES)){ + final String location = args.getString(0); + cordova.getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + me.showMoreApps(location, _callback); + } + }); + } else if (action.equals(ACTION_CACHE_MOREGAMES)){ + final String location = args.getString(0); + cordova.getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + me.preloadMoreApps(location, _callback); + } + }); + } else if (action.equals(ACTION_SHOW_REWARDVIDEO)){ + final String location = args.getString(0); + cordova.getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + me.showRewardedVideo(location, _callback); + } + }); + } else if (action.equals(ACTION_CACHE_REWARDVIDEO)){ + final String location = args.getString(0); + cordova.getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + me.preloadRewardedVideo(location, _callback); + } + }); + } else if (action.equals(ACTION_HAS_REWARDVIDEO)){ + final String location = args.getString(0); + cordova.getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + me.hasRewardedVideo(location, _callback); + } + }); + } else if (action.equals(ACTION_SET_DISMISSCALLBACK)){ + final String location = args.getString(0); + cordova.getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + me.setDidDismissInterstitialCallback(location, _callback); + } + }); + } + else return false; //easier to return true in all cases but this one... + return true; } + /** + * Some functions required for state change... + */ +// @Override +// public void onStart() { +// super.onStart(); +// Chartboost.onStart( cordova.getActivity() ); +// } + @Override - public void onResume(boolean multitasking) { - Chartboost.onResume(cordova.getActivity()); - super.onResume(multitasking); + public void onStop() { + super.onStop(); + Chartboost.onStop( cordova.getActivity() ); } @Override public void onPause(boolean multitasking) { - Chartboost.onPause(cordova.getActivity()); super.onPause(multitasking); + Chartboost.onPause( cordova.getActivity() ); } + @Override + public void onResume(boolean multitasking) { + super.onResume(multitasking); + Chartboost.onResume( cordova.getActivity() ); + } + +// @Override +// public void onBackPressed() { +// // If an interstitial is on screen, close it. Otherwise continue as normal. +// if (Chartboost.onBackPressed()) +// return; +// else +// super.onBackPressed(); +// } @Override - public boolean execute(String action, JSONArray args, CallbackContext callback) throws JSONException{ - - if (action.equals(ACTION_INI_CHARBOOST)) { - final String appId = args.getString(0); - final String appSignature = args.getString(1); - - cordova.getActivity().runOnUiThread(new Runnable() { - @Override - public void run() { - Chartboost.startWithAppId(cordova.getActivity(), appId , appSignature); - Chartboost.onCreate(cordova.getActivity()); - Chartboost.onStart(cordova.getActivity()); - } - }); - + public void onDestroy() { + // TODO Auto-generated method stub + super.onDestroy(); + Chartboost.onDestroy( cordova.getActivity() ); + } + + /** + * Functions for setting up Chartboost and handling Callbacks... + */ + /** + * Register callback to call later... + */ + private HashMap callbackMap; + public void registerCallback(CallbackContext callback, java.lang.String location, java.lang.String funcId) { + if (null == callbackMap) callbackMap = new HashMap(); + java.lang.String callbackKey = location + ":" + funcId; + callbackMap.put(callbackKey, callback); + } + /** + * Register callback to call later... + */ + public void doSuccessCallback(java.lang.String location, java.lang.String funcId) { + if (null == callbackMap) callbackMap = new HashMap(); + java.lang.String callbackKey = location + ":" + funcId; + CallbackContext callContext = callbackMap.get(callbackKey); + if (callContext != null) { + callbackMap.remove(callbackKey);//remove our callback from queue + callContext.success("{\"location\": \""+location+"\",\"function\": \""+funcId+"\"}"); + } + } + /** + * Register callback to call later... + */ + public void doFailureCallback(java.lang.String location, java.lang.String funcId) { + if (null == callbackMap) callbackMap = new HashMap(); + java.lang.String callbackKey = location + ":" + funcId; + CallbackContext callContext = callbackMap.get(callbackKey); + if (callContext != null) { + callbackMap.remove(callbackKey);//remove our callback from queue + callContext.error("{\"location\": \""+location+"\",\"function\": \""+funcId+"\"}"); + } + } + + public void chartboost_init(java.lang.String app_id, java.lang.String app_sig) { + Chartboost.onStart( cordova.getActivity() );//init cb session as onstart override isn't working.. + Chartboost.startWithAppId(cordova.getActivity(), app_id, app_sig); + Chartboost.setDelegate( delegate ); + Chartboost.onCreate( cordova.getActivity() ); + } + + public void showInterstitial(java.lang.String location, CallbackContext callback) { + this.registerCallback(callback, location, ACTION_SHOW_INTERSTITIAL); + Chartboost.showInterstitial( location ); + } + + public void showMoreApps(java.lang.String location, CallbackContext callback) { + this.registerCallback(callback, location, ACTION_SHOW_MOREGAMES); + Chartboost.showMoreApps( location ); + } + + public void preloadInterstitial(java.lang.String location, CallbackContext callback) { + this.registerCallback(callback, location, ACTION_CACHE_INTERSTITIAL); + Chartboost.cacheInterstitial( location ); + } + + public void preloadMoreApps(java.lang.String location, CallbackContext callback) { + this.registerCallback(callback, location, ACTION_CACHE_MOREGAMES); + Chartboost.cacheMoreApps( location ); + } + + public void showRewardedVideo(java.lang.String location, CallbackContext callback) { + this.registerCallback(callback, location, ACTION_SHOW_REWARDVIDEO); + Chartboost.showRewardedVideo( location ); + } + + public void preloadRewardedVideo(java.lang.String location, CallbackContext callback) { + this.registerCallback(callback, location, ACTION_CACHE_REWARDVIDEO); + Chartboost.cacheRewardedVideo( location ); + } + + public void hasRewardedVideo(java.lang.String location, CallbackContext callback) { + this.registerCallback(callback, location, ACTION_HAS_REWARDVIDEO); + if (Chartboost.hasRewardedVideo( location )) { + this.doSuccessCallback(location, ACTION_HAS_REWARDVIDEO); + } else { + this.doFailureCallback(location, ACTION_HAS_REWARDVIDEO); + } + } + public void setDidDismissInterstitialCallback(java.lang.String location, CallbackContext callback) { + this.registerCallback(callback, location, ACTION_SET_DISMISSCALLBACK); + //this is handled in the delegate... + } + + /** + * Chartboost Delegate + */ + private ChartboostDelegate delegate = new ChartboostDelegate() { + + @Override + public boolean shouldRequestInterstitial(String location) { return true; - }else if(action.equals(ACTION_SHOW_INTERSTITIAL)){ - final String location = args.getString(0); - - cordova.getActivity().runOnUiThread(new Runnable() { - @Override - public void run() { - Chartboost.showInterstitial(location); - } - }); } + + @Override + public boolean shouldDisplayInterstitial(String location) { + return true; + } + + @Override + public void didCacheInterstitial(String location) { + me.doSuccessCallback(location, ACTION_CACHE_INTERSTITIAL); + } + + @Override + public void didFailToLoadInterstitial(String location, CBImpressionError error) { + android.util.Log.e(TAG, error.toString()); + me.doFailureCallback(location, ACTION_CACHE_INTERSTITIAL); + me.doFailureCallback(location, ACTION_SHOW_INTERSTITIAL); + } + + @Override + public void didDismissInterstitial(String location) { + //attempt to callback to JS... + me.doSuccessCallback(location, ACTION_SET_DISMISSCALLBACK); + } + + @Override + public void didCloseInterstitial(String location) { } + @Override + public void didClickInterstitial(String location) { } + + @Override + public void didDisplayInterstitial(String location) { + me.doSuccessCallback(location, ACTION_SHOW_INTERSTITIAL); + } + + @Override + public boolean shouldRequestMoreApps(String location) { + return true; + } + + @Override + public boolean shouldDisplayMoreApps(String location) { + return true; + } + + @Override + public void didFailToLoadMoreApps(String location, CBImpressionError error) { + me.doFailureCallback(location, ACTION_SHOW_MOREGAMES); + me.doFailureCallback(location, ACTION_CACHE_MOREGAMES); + } + + @Override + public void didCacheMoreApps(String location) { + me.doSuccessCallback(location, ACTION_CACHE_MOREGAMES); + } + + @Override + public void didDismissMoreApps(String location) { + me.doSuccessCallback(location, ACTION_SET_DISMISSCALLBACK); + } + + @Override + public void didCloseMoreApps(String location) { } + @Override + public void didClickMoreApps(String location) { } + + @Override + public void didDisplayMoreApps(String location) { + me.doSuccessCallback(location, ACTION_SHOW_MOREGAMES); + } + + @Override + public void didFailToRecordClick(String uri, CBClickError error) { } + + @Override + public boolean shouldDisplayRewardedVideo(String location) { + return true; + } + + @Override + public void didCacheRewardedVideo(String location) { + me.doSuccessCallback(location, ACTION_CACHE_REWARDVIDEO); + } + + @Override + public void didFailToLoadRewardedVideo(String location, CBImpressionError error) { + me.doFailureCallback(location, ACTION_SHOW_REWARDVIDEO); + me.doFailureCallback(location, ACTION_CACHE_REWARDVIDEO); + } + + @Override + public void didDismissRewardedVideo(String location) { + me.doSuccessCallback(location, ACTION_SET_DISMISSCALLBACK); + } + @Override + public void didCloseRewardedVideo(String location) { } + @Override + public void didClickRewardedVideo(String location) { } + @Override + public void didCompleteRewardedVideo(String location, int reward) { } - return false; - } + @Override + public void didDisplayRewardedVideo(String location) { + me.doSuccessCallback(location, ACTION_SHOW_REWARDVIDEO); + } + @Override + public void willDisplayVideo(String location) { } + + }; + +// @SuppressLint("ClickableViewAccessibility") +// public void onInPlayButtonClick(View view) { +// String toastStr = "Loading InPlay"; +// Log.i(TAG, toastStr); +// Toast.makeText(this, toastStr, +// Toast.LENGTH_SHORT).show(); +// +// final CBInPlay inPlay = CBInPlay.getInPlay(CBLocation.LOCATION_GAMEOVER); +// +// if(inPlay != null) { +// ImageView myview = (ImageView) findViewById(R.id.inplayView); +// myview.setImageBitmap(inPlay.getAppIcon()); +// inPlay.show(); +// myview.setOnTouchListener(new View.OnTouchListener() { +// +// @Override +// public boolean onTouch(View v, MotionEvent event) { +// inPlay.click(); +// return false; +// } +// }); +// } +// } +// +// public void onPreloadInPlayButtonClick(View view) { +// String toastStr = "Preloading InPlay"; +// Log.i(TAG, toastStr); +// CBInPlay.cacheInPlay(CBLocation.LOCATION_GAMEOVER); +// } } \ No newline at end of file diff --git a/src/ios/Chartboost.m b/src/ios/Chartboost.m index e8fe531..db409c2 100644 --- a/src/ios/Chartboost.m +++ b/src/ios/Chartboost.m @@ -6,7 +6,8 @@ #import @interface ChartboostPlugin : CDVPlugin { - NSMutableArray* _queue; +// NSMutableArray* _queue; + NSMutableDictionary* _queue; } -(void) init:(CDVInvokedUrlCommand*)command; @@ -21,12 +22,15 @@ -(void) init:(CDVInvokedUrlCommand*)command { NSString* appSignature = [command.arguments objectAtIndex:1]; NSString* callbackId = command.callbackId; - if(_queue == nil){ - _queue = [NSMutableArray array]; - } - - [_queue addObject: callbackId]; - [Chartboost startWithAppId:appId +// if(_queue == nil){ +// _queue = [NSMutableArray array]; +// } + // initialization has no delegate method, so just init callback queue + if(_queue == nil) { + _queue = [[NSMutableDictionary alloc] init]; + } + + [Chartboost startWithAppId:appId appSignature:appSignature delegate:self]; @@ -36,14 +40,92 @@ -(void) init:(CDVInvokedUrlCommand*)command { [Chartboost cacheInterstitial:CBLocationDefault]; } +#pragma mark - +#pragma mark Chartboost interstitials + -(void) showInterstitial:(CDVInvokedUrlCommand*)command { NSString* location = [command.arguments objectAtIndex:0]; NSString* callbackId = command.callbackId; + NSString* callbackKey = [NSString stringWithFormat:@"showInterstitial:%@", location]; - [_queue addObject: callbackId]; +// [_queue addObject: callbackId]; + [_queue setObject: callbackId forKey:callbackKey]; [Chartboost showInterstitial:location]; } +-(void) setDidDismissInterstitialCallback:(CDVInvokedUrlCommand*)command { + NSString* location = [command.arguments objectAtIndex:0]; + NSString* callbackId = command.callbackId; + NSString* callbackKey = [NSString stringWithFormat:@"setDidDismissInterstitialCallback:%@", location]; + [_queue setObject: callbackId forKey:callbackKey]; +} + +-(void) cacheInterstitial:(CDVInvokedUrlCommand*)command { + NSString* location = [command.arguments objectAtIndex:0]; + NSString* callbackId = command.callbackId; + NSString* callbackKey = [NSString stringWithFormat:@"cacheInterstitial:%@", location]; + +// [_queue addObject: callbackId]; + [_queue setObject: callbackId forKey:callbackKey]; + [Chartboost cacheInterstitial:location]; +} + +#pragma mark - +#pragma mark Chartboost MoreGames + +-(void) showMoreGames:(CDVInvokedUrlCommand*)command { + NSString* location = [command.arguments objectAtIndex:0]; + NSString* callbackId = command.callbackId; + NSString* callbackKey = [NSString stringWithFormat:@"showMoreGames:%@", location]; + + [_queue setObject: callbackId forKey:callbackKey]; + [Chartboost showMoreApps:location]; +} + +-(void) cacheMoreGames:(CDVInvokedUrlCommand*)command { + NSString* location = [command.arguments objectAtIndex:0]; + NSString* callbackId = command.callbackId; + NSString* callbackKey = [NSString stringWithFormat:@"cacheMoreGames:%@", location]; + + [_queue setObject: callbackId forKey:callbackKey]; + [Chartboost cacheMoreApps:location]; +} + +#pragma mark - +#pragma mark Chartboost rewarded video + +-(void) showRewardedVideo:(CDVInvokedUrlCommand*)command { + NSString* location = [command.arguments objectAtIndex:0]; + NSString* callbackId = command.callbackId; + NSString* callbackKey = [NSString stringWithFormat:@"showRewardedVideo:%@", location]; + + [_queue setObject: callbackId forKey:callbackKey]; + [Chartboost showRewardedVideo:location]; +} + +-(void) cacheRewardedVideo:(CDVInvokedUrlCommand*)command { + NSString* location = [command.arguments objectAtIndex:0]; + NSString* callbackId = command.callbackId; + NSString* callbackKey = [NSString stringWithFormat:@"cacheRewardedVideo:%@", location]; + + [_queue setObject: callbackId forKey:callbackKey]; + [Chartboost cacheRewardedVideo:location]; +} + +-(void) hasRewardedVideo:(CDVInvokedUrlCommand*)command { + NSString* location = [command.arguments objectAtIndex:0]; + NSString* callbackId = command.callbackId; + + BOOL hasRewardedVideo = [Chartboost hasRewardedVideo:location]; + + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:hasRewardedVideo]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; + +} + +#pragma mark - +#pragma mark ChartboostDelegate + -(BOOL) shouldRequestInterstitialsInFirstSession { return NO; } @@ -58,11 +140,23 @@ -(BOOL) shouldDisplayInterstitial:(CBLocation)location{ return YES; } +//called after intersittial is dismissed +- (void)didDismissInterstitial:(CBLocation)location { + NSString* callbackKey = [NSString stringWithFormat:@"setDidDismissInterstitialCallback:%@", location]; + if(_queue != nil && [_queue objectForKey:callbackKey] != nil){ + NSString* callbackId = [_queue objectForKey:callbackKey]; + [_queue removeObjectForKey:callbackKey]; + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@""]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; + } +} + // Called after an interstitial has been displayed on the screen. -(void) didDisplayInterstitial:(CBLocation)location{ - if(_queue != nil && _queue.count > 0){ - NSString* callbackId = _queue[0]; - [_queue removeObjectAtIndex:0]; + NSString* callbackKey = [NSString stringWithFormat:@"showInterstitial:%@", location]; + if(_queue != nil && [_queue objectForKey:callbackKey] != nil){ + NSString* callbackId = [_queue objectForKey:callbackKey]; + [_queue removeObjectForKey:callbackKey]; CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@""]; [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; @@ -72,10 +166,11 @@ -(void) didDisplayInterstitial:(CBLocation)location{ // Called after an interstitial has been loaded from the Chartboost API // servers and cached locally. -(void) didCacheInterstitial:(CBLocation)location{ - if(_queue != nil && _queue.count > 0){ - NSString* callbackId = _queue[0]; - [_queue removeObjectAtIndex:0]; - + NSString* callbackKey = [NSString stringWithFormat:@"cacheInterstitial:%@", location]; + if(_queue != nil && [_queue objectForKey:callbackKey] != nil){ + NSString* callbackId = [_queue objectForKey:callbackKey]; + [_queue removeObjectForKey:callbackKey]; + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@""]; [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; } @@ -85,13 +180,116 @@ -(void) didCacheInterstitial:(CBLocation)location{ // servers but failed. -(void) didFailToLoadInterstitial:(CBLocation)location withError:(CBLoadError)error{ - if(_queue != nil && _queue.count > 0){ - NSString* callbackId = _queue[0]; - [_queue removeObjectAtIndex:0]; - - CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Error loading the interstitial"]; - [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; - } + NSString* callbackKey = [NSString stringWithFormat:@"cacheInterstitial:%@", location]; + if(_queue != nil && [_queue objectForKey:callbackKey] != nil){ + NSString* callbackId = [_queue objectForKey:callbackKey]; + [_queue removeObjectForKey:callbackKey]; + + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Error loading the interstitial"]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; + } + callbackKey = [NSString stringWithFormat:@"showInterstitial:%@", location]; + if(_queue != nil && [_queue objectForKey:callbackKey] != nil){ + NSString* callbackId = [_queue objectForKey:callbackKey]; + [_queue removeObjectForKey:callbackKey]; + + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Error loading the interstitial"]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; + } +} + +// Called before a MoreApps page will be displayed on the screen. +- (BOOL)shouldDisplayMoreApps:(CBLocation)location { + return YES; +} + +// Called after a MoreApps page has been loaded from the Chartboost API +// servers and cached locally. +- (void)didCacheMoreApps:(CBLocation)location { + NSString* callbackKey = [NSString stringWithFormat:@"cacheMoreGames:%@", location]; + if(_queue != nil && [_queue objectForKey:callbackKey] != nil){ + NSString* callbackId = [_queue objectForKey:callbackKey]; + [_queue removeObjectForKey:callbackKey]; + + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@""]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; + } +} + +// Called after a MoreApps page attempted to load from the Chartboost API +// servers but failed. +- (void)didFailToLoadMoreApps:(CBLocation)location + withError:(CBLoadError)error { + NSString* callbackKey = [NSString stringWithFormat:@"cacheMoreGames:%@", location]; + if(_queue != nil && [_queue objectForKey:callbackKey] != nil){ + NSString* callbackId = [_queue objectForKey:callbackKey]; + [_queue removeObjectForKey:callbackKey]; + + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Error loading MoreGames"]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; + } + callbackKey = [NSString stringWithFormat:@"showMoreGames:%@", location]; + if(_queue != nil && [_queue objectForKey:callbackKey] != nil){ + NSString* callbackId = [_queue objectForKey:callbackKey]; + [_queue removeObjectForKey:callbackKey]; + + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Error loading MoreGames"]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; + } +} + +// Called before a rewarded video will be displayed on the screen. +- (BOOL)shouldDisplayRewardedVideo:(CBLocation)location { + return YES; } -@end \ No newline at end of file +// Called after a rewarded video has been loaded from the Chartboost API +// servers and cached locally. +- (void)didCacheRewardedVideo:(CBLocation)location { + NSString* callbackKey = [NSString stringWithFormat:@"cacheRewardedVideo:%@", location]; + if(_queue != nil && [_queue objectForKey:callbackKey] != nil){ + NSString* callbackId = [_queue objectForKey:callbackKey]; + [_queue removeObjectForKey:callbackKey]; + + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@""]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; + } +} + +// Called after a rewarded video has attempted to load from the Chartboost API +// servers but failed. +- (void)didFailToLoadRewardedVideo:(CBLocation)location + withError:(CBLoadError)error { + NSString* callbackKey = [NSString stringWithFormat:@"cacheRewardedVideo:%@", location]; + if(_queue != nil && [_queue objectForKey:callbackKey] != nil){ + NSString* callbackId = [_queue objectForKey:callbackKey]; + [_queue removeObjectForKey:callbackKey]; + + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Error loading video"]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; + } + callbackKey = [NSString stringWithFormat:@"showRewardedVideo:%@", location]; + if(_queue != nil && [_queue objectForKey:callbackKey] != nil){ + NSString* callbackId = [_queue objectForKey:callbackKey]; + [_queue removeObjectForKey:callbackKey]; + + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Error loading video"]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; + } +} + +// Called after a rewarded video has been viewed completely and user is eligible for reward. +- (void)didCompleteRewardedVideo:(CBLocation)location + withReward:(int)reward { + NSString* callbackKey = [NSString stringWithFormat:@"showRewardedVideo:%@", location]; + if(_queue != nil && [_queue objectForKey:callbackKey] != nil){ + NSString* callbackId = [_queue objectForKey:callbackKey]; + [_queue removeObjectForKey:callbackKey]; + + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Video has been completely viewed"]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; + } +} + + +@end diff --git a/www/chartboost.js b/www/chartboost.js index af51138..e8766d2 100644 --- a/www/chartboost.js +++ b/www/chartboost.js @@ -5,10 +5,38 @@ var cordova = require('cordova'); Chartboost.init = function(appId, appSignature) { - exec(null, null, "ChartboostPlugin", "init", [ - appId, appSignature ]); + exec(null, null, "ChartboostPlugin", "init", [appId, appSignature]); } Chartboost.showInterstitial = function(sucessCallback, failCallback, location) { exec(sucessCallback, failCallback, "ChartboostPlugin", "showInterstitial", [location]); } + + Chartboost.cacheInterstitial = function(sucessCallback, failCallback, location) { + exec(sucessCallback, failCallback, "ChartboostPlugin", "cacheInterstitial", [location]); + } + + Chartboost.showMoreGames = function(sucessCallback, failCallback, location) { + exec(sucessCallback, failCallback, "ChartboostPlugin", "showMoreGames", [location]); + } + + Chartboost.cacheMoreGames = function(sucessCallback, failCallback, location) { + exec(sucessCallback, failCallback, "ChartboostPlugin", "cacheMoreGames", [location]); + } + + Chartboost.showRewardedVideo = function(sucessCallback, failCallback, location) { + exec(sucessCallback, failCallback, "ChartboostPlugin", "showRewardedVideo", [location]); + } + + Chartboost.cacheRewardedVideo = function(sucessCallback, failCallback, location) { + exec(sucessCallback, failCallback, "ChartboostPlugin", "cacheRewardedVideo", [location]); + } + + Chartboost.hasRewardedVideo = function(sucessCallback, failCallback, location) { + exec(sucessCallback, failCallback, "ChartboostPlugin", "hasRewardedVideo", [location]); + } + + Chartboost.setDidDismissInterstitialCallback = function(sucessCallback, failCallback, location) { + exec(sucessCallback, failCallback, "ChartboostPlugin", "setDidDismissInterstitialCallback", [location]); + } +