UNPKG

cordova-plugin-appodeal-framework

Version:

Appodeal's supply-side platform is designed and built by veteran publishers, for publishers. Appodeal is not an ad network, it is a new approach to monetizing for publishers.

120 lines (103 loc) 5.89 kB
<!DOCTYPE html> <html> <head> <title>Hello Appodeal</title> </head> <body style="background-color:red;/* position: fixed; top: 0; bottom: 0; left: 0; right: 0; width: 100%; height: 100%;*/"> <script type="text/javascript" src="cordova.js"></script> <script type="text/javascript" src="js/index.js"></script> <script type="text/javascript"> function initialize() { var appodealKey; if( /(android)/i.test(navigator.userAgent) ) { // set appkey for android || amazon-fireos appKey = "28655d78fce1bea39175bf1f5f0c055ecefcda1b33bf6bdd"; } else if(/(ipod|iphone|ipad)/i.test(navigator.userAgent)) { // set appkey for ios appKey = "4b46ef930cd37cf11da84ae4d41019abb7234d5bbce3f000"; }; Appodeal.setLogLevel(Appodeal.LogLevel.verbose); // set logging level (none || debug || verbose) Appodeal.setTesting(false); // set test mode enabled || disabled Appodeal.setBannerAnimation(false); Appodeal.setBannerBackground(false); Appodeal.setSmartBanners(false); Appodeal.set728x90Banners(false); Appodeal.setChildDirectedTreatment(false); Appodeal.muteVideosIfCallsMuted(true); setUserSettings(); // set user data Appodeal.setAutoCache(Appodeal.REWARDED_VIDEO, false); Appodeal.initialize(appKey, Appodeal.INTERSTITIAL | Appodeal.BANNER | Appodeal.REWARDED_VIDEO); Appodeal.setCustomIntegerRule("rule_name", 1); Appodeal.setCustomDoubleRule("rule_name", 1.0); Appodeal.setCustomBooleanRule("rule_name", true); Appodeal.setCustomStringRule("rule_name", "rule_value"); registerAdEvents(); } function setUserSettings() { Appodeal.setUserId("awesome_user"); Appodeal.setAge(25); Appodeal.setGender("female"); } function showInterstitial() { Appodeal.show(Appodeal.INTERSTITIAL, function(result) { // check if INTERSTITIAL was shown if (result) { // returns true or false console.log("Appodeal Ads Shown"); } }); } function showRewardedVideo() { Appodeal.getRewardParameters(function(result) { console.log("Appodeal Reward Amount:" + result.amount); console.log("Appodeal Reward Currency:" + result.currency); }); Appodeal.isLoaded(Appodeal.REWARDED_VIDEO, function(result) { // check if REWARDED_VIDEO was loaded if (result) { // returns true or false Appodeal.showWithPlacement(Appodeal.REWARDED_VIDEO, "rewarded_video_button"); } else { Appodeal.cache(Appodeal.REWARDED_VIDEO); } }); } function showBanner() { Appodeal.canShow(Appodeal.BANNER_BOTTOM, function(result) { // check if BANNER_BOTTOM can be shown for 'default' placement if(result) { // returns true or false Appodeal.show(Appodeal.BANNER_BOTTOM); } }); } function hideBanner() { Appodeal.hide(Appodeal.BANNER); } function showTestScreen() { Appodeal.showTestScreen(); } function registerAdEvents() { Appodeal.setInterstitialCallbacks(function(container){ if(container.event == 'onLoaded') document.getElementById("callbackContainer").innerHTML = "Appodeal. Interstitial. " + container.event + ", isPrecache: " + container.isPrecache; else document.getElementById("callbackContainer").innerHTML = "Appodeal. Interstitial. " + container.event + ", isPrecache: " + container.isPrecache; }); Appodeal.setBannerCallbacks(function(container){ if(container.event == 'onLoaded') document.getElementById("callbackContainer").innerHTML = "Appodeal. Banner. " + container.event + ", height: " + container.height + ", isPrecache: " + container.isPrecache; document.getElementById("callbackContainer").innerHTML = "Appodeal. Banner. " + container.event; }); Appodeal.setRewardedVideoCallbacks(function(container){ if(container.event == 'onClosed') document.getElementById("callbackContainer").innerHTML = "Appodeal. Rewarded. " + container.event + ", finished: " + container.finished; else if(container.event == 'onFinished') document.getElementById("callbackContainer").innerHTML = "Appodeal. Rewarded. " + container.event + ", amount: " + container.amount + ", name: " + container.name; else document.getElementById("callbackContainer").innerHTML = "Appodeal. Rewarded. " + container.event; }); } </script> <p style="font-size:25px;color:white;">Appodeal Cordova Demo</p> <button id="initialize" onclick="initialize();" style="width:100%;height:50px; margin-top:10px;background-color:white;color:red;">Initialize</button> <button id="interstitial" onclick="showInterstitial();" style="width:100%;height:50px; margin-top:10px;background-color:white;color:red;">Interstitial</button> <button id="rewarded" onclick="showRewardedVideo();" style="width:100%;height:50px; margin-top:10px;background-color:white;color:red;">Rewarded Video</button> <button id="showBanner" onclick="showBanner();" style="width:100%;height:50px; margin-top:10px;background-color:white;color:red;">Show Banner</button> <button id="showTestScreen" onclick="showTestScreen();" style="width:100%;height:50px; margin-top:10px;background-color:white;color:red;">Show TestScreen</button> <button id="hideBanner" onclick="hideBanner();" style="width:100%;height:50px; margin-top:10px;background-color:white;color:red;">Hide Banner</button> <p id="callbackContainer">Callback events data</p> </body> </html>