AdMob

53 posts, 0 answers
  1. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 09 Apr 2014 Link to this post

    Hello Joris,

    Everything looks correct in the posted plugin.xml. Please, make sure the "window.plugins.AdMob == undifined" check is being executed after the deviceReady event. Otherwise it is very likely that the AdMob will be undefined.

    If the above is not the case, please contact us again and we will help you get to the bottom of this.

    Regards,
    Kaloyan
    Telerik
     

    Share what you think about AppBuilder and Telerik Platform with us in our feedback portal, so we can become even better!

     
  2. Andrew Galea
    Andrew Galea avatar
    22 posts
    Member since:
    Nov 2009

    Posted 12 Apr 2014 in reply to Kaloyan Link to this post

    I have followed all the instructions in this thread and I am getting  a similar error "Uncaught TypeError: Cannot read property 'AdMob' of undefined". I copied the script from the test.html page included in the plugin as follows:

    document.addEventListener('deviceready', function () {
            navigator.splashscreen.hide();       
             
            var admob_ios_key = 'a151e6d43c5a28f';
            var admob_android_key = 'a151e6d65b12438';
            var adId = (navigator.userAgent.indexOf('Android') >=0) ? admob_android_key : admob_ios_key;
             
            if ( window.plugins.AdMob ) {
                var am = window.plugins.AdMob;
                am.createBannerView(
                        {
                            'publisherId': adId,
                            'adSize': am.AD_SIZE.BANNER,
                            'bannerAtTop': true
                        }, function() {
                            am.requestAd( { 'isTesting':false }, function() {
                                am.showAd( true );
                            }, function() {
                                alert('failed to request ad'); 
                            })
                        }, function(){
                            alert( "failed to create ad view" );
                        });
            } else {
                alert('AdMob plugin not available/ready.');
            }
        }, false);

    Plugin.xml is as follows:

    <?xml version="1.0" encoding="UTF-8"?>
     
        id="com.rjfun.cordova.plugin.admob"
        version="1.1">
           
        <name>AdMob</name>
        <description>Add AdMob support</description>
        <author>Liming Xie</author>
        <license>MIT</license>
     
        <engines>
            <engine name="cordova" version=">=2.9" />
        </engines>
        <plugin name='AdMob' value='com.google.cordova.plugin.admob'/>
        <js-module src="www/AdMob.js" name="AdMob">
            <clobbers target="window.plugins.AdMob" />
        </js-module>
        <source-file src="src/android/libs/GoogleAdMobAdsSdk-6.4.1.jar" target-dir="libs" />
     
        <!-- android -->
        <platform name="android">
            <!-- <dependency id="com.google.playservices" version=">=15.0.1"/> -->
            <config-file target="res/xml/config.xml" parent="/*">
                <feature name="AdMob">
                    <param name="android-package" value="com.rjfun.cordova.plugin.AdMob"/>
                </feature>
            </config-file>
            <config-file target="AndroidManifest.xml" parent="/manifest/application">
                <meta-data android:name="com.google.android.gms.version"
                    android:value="4323000"/>
            </config-file>
            <config-file target="AndroidManifest.xml" parent="/manifest/application">
                <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
                    android:name="com.google.android.gms.ads.AdActivity" />
              </config-file>
            <config-file target="AndroidManifest.xml" parent="/*">
                <uses-permission android:name="android.permission.INTERNET"/>
                <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
              </config-file>
               
            <source-file src="src/android/AdMob.java" target-dir="src/com/rjfun/cordova/plugin" />
            <source-file src="src/android/libs/google-play-services.jar" target-dir="libs" />
         </platform>
          
         <!-- ios -->
         <platform name="ios">   
             <config-file target="config.xml" parent="/*">
                 <feature name="AdMob">
                     <param name="ios-package" value="CDVAdMob" />
                 </feature>
             </config-file>
              
             <header-file src="src/ios/CDVAdMob.h" />
             <source-file src="src/ios/CDVAdMob.m" />
              
             <header-file src="src/ios/GADAdMobExtras.h" />
             <header-file src="src/ios/GADAdNetworkExtras.h" />
             <header-file src="src/ios/GADAdSize.h" />
             <header-file src="src/ios/GADBannerView.h" />
             <header-file src="src/ios/GADBannerViewDelegate.h" />
             <header-file src="src/ios/GADInterstitial.h" />
             <header-file src="src/ios/GADInterstitialDelegate.h" />
             <header-file src="src/ios/GADRequest.h" />
             <header-file src="src/ios/GADRequestError.h" />
             <source-file src="src/ios/libGoogleAdMobAds.a" framework="true" />
              
             <framework src="StoreKit.framework" />
             <framework src="AudioToolbox.framework" />
             <framework src="MessageUI.framework" />
             <framework src="SystemConfiguration.framework" />
             <framework src="CoreGraphics.framework" />
             <framework src="AdSupport.framework" />
        </platform>
               
    </plugin>

    Any suggestions on trying to get this to work?

    Regards,
    Andrew


  3. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 15 Apr 2014 Link to this post

    Hello everyone,

    Because of the high interest in the AdMob plugin I made a very simple app that implements it.
    Please find it attached to this reply. It works both for Android and iOS and it is tested on Android 4.3 and iOS 7.1 versions.
    Note that you have to replace the keys below with yours from apps.admob.com :

    var admob_ios_key = 'ca-app-pub-1882245665150742/5173927112';
    var admob_android_key = 'ca-app-pub-1882245665150742/7348664319';

    Thanks.

    Regards,
    Zdravko
    Telerik
     

    Share what you think about AppBuilder and Telerik Platform with us in our feedback portal, so we can become even better!

     
  4. Andrew Galea
    Andrew Galea avatar
    22 posts
    Member since:
    Nov 2009

    Posted 15 Apr 2014 in reply to Zdravko Link to this post

    Absolutely brilliant Zdravko. Fantastic customer support and once again my decision to go with AppBuilder is reinforced.

    Got it all working on both Android and iOS. 

    Thanks again,

    Andrew
  5. James
    James avatar
    1 posts
    Member since:
    Apr 2014

    Posted 04 Jun 2014 in reply to Zdravko Link to this post

    I've tried the ApMob plugin and even the attached sample but nothing works. Whatever I've try the plugin is never found, always undefined!

    Has anybody got this to work with Telerik AppBuilder?

    Without an option to monetize your apps the framework is a waste of time!

    Are there any other options to add adverts using Cordova and AppBuilder?


    Can you please retest this sample and give an update?
  6. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 09 Jun 2014 Link to this post

    Hello James,

    The app is working as expected.

    Do you by any chance test the app in our Simulator or via AppBuilder Companion app?
    If this is the case notice that both tools do not support custom plugins and the best approach to test this app is to deploy it as described here or install the app manually using the build package.
    Thanks.

    Regards,
    Zdravko
    Telerik
     

    Share what you think about AppBuilder and Telerik Platform with us in our feedback portal, so we can become even better!

     
  7. Daniel
    Daniel avatar
    15 posts
    Member since:
    Jul 2013

    Posted 10 Jun 2014 in reply to Zdravko Link to this post

    I also do Windows Phone apps, I take it all that should be required is to add an admob_WINPHONE_key and figure out the useragent for iOS or WinPhone...?

    am going to try and work on it tonight, but thought you might have some insight for me before i start hitting my head on the wall.. :)
  8. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 13 Jun 2014 Link to this post

    Hi Daniel,

    Unfortunately, the solution provided by Zdravko does not support Window Phone. Further, my search for another possible approaches did not find anything that could help. Nevertheless, if we come to something appropriate, we will let you know right away.

    Thank you for the understanding.

    Regards,
    Kaloyan
    Telerik
     

    Share what you think about AppBuilder and Telerik Platform with us in our feedback portal, so we can become even better!

     
  9. Alex
    Alex avatar
    54 posts
    Member since:
    Feb 2009

    Posted 17 Jun 2014 Link to this post

    I have used Zdravko's sample project and followed his instructions, but I keep getting the alert "AdMob plugin not available/ready." What could be causing it.

    The latest AdMob plugin contains teh Windows Phone 8 support. Has anyone tried it?
  10. Jan-Dirk
    Jan-Dirk avatar
    327 posts
    Member since:
    Jun 2012

    Posted 18 Jun 2014 in reply to Alex Link to this post

    Are you using a real device or the emulator? AdMob won't work in the emulator!
  11. Daniel
    Daniel avatar
    15 posts
    Member since:
    Jul 2013

    Posted 18 Jun 2014 Link to this post

    You got me all excited about the AdMob plugin supporting Windows Phone.  However i am having some issues getting it to compile on the cloud.

    I took the sample app from Zdravko, updated the plugin directory with the new version here: https://github.com/floatinghotpot/cordova-plugin-admob.

    When I "Build & Deploy" I get the following error:


    [2014-06-18 08:12:23.563] Log (Info,None): Project "AdTest.proj" (default targets):
     Error:  The "ResolveAssemblyReference" task failed unexpectedly.
    Microsoft.Build.Shared.InternalErrorException: MSB0001: Internal MSBuild Error: Unexpected CopyLocal flag.
       at Microsoft.Build.Tasks.CopyLocalStateUtility.IsCopyLocal(CopyLocalState state)
       at Microsoft.Build.Tasks.ResolveAssemblyReference.LogResults(ReferenceTable dependencyTable, DependentAssembly[] idealAssemblyRemappings, AssemblyNameReference[] idealAssemblyRemappingsIdentities, ArrayList generalResolutionExceptions)
       at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute(FileExists fileExists, DirectoryExists directoryExists, GetDirectories getDirectories, GetAssemblyName getAssemblyName, GetAssemblyMetadata getAssemblyMetadata, GetRegistrySubKeyNames getRegistrySubKeyNames, GetRegistrySubKeyDefaultValue getRegistrySubKeyDefaultValue, GetLastWriteTime getLastWriteTime, GetAssemblyRuntimeVersion getRuntimeVersion, OpenBaseKey openBaseKey, CheckIfAssemblyInGac checkIfAssemblyIsInGac, IsWinMDFile isWinMDFile, ReadMachineTypeFromPEHeader readMachineTypeFromPEHeader)
       at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute()
       at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
       at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext() in C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets (1605,5)
     Error: Could not copy the file "\\icewin1.telerik.local\t\64ed1052f356\bin\AdTest.xap" because it was not found.
    Done building project "AdTest.proj" -- FAILED.


    I noticed the 'UnexpectedCopyLocal' flag, and i tried it in the Visual Studio extention, and changed the Build Action from Content to Compile.

    Now I get:

    C:\Users\Daniel\AppData\Local\Microsoft\VisualStudio\12.0\Extensions\c2f151hw.s1z\Targets\Build.targets(158,3): error : Server build failed. Server output: Project "AdMob_Test.proj" (default targets):
    Error: Error during processing of action! Attempting to revert...
    Done building project "AdMob_Test.proj" -- FAILED.
    .
    Done building project "AdMob_Test.iceproj" -- FAILED.

    Build FAILED.


    Not one of the more useful error messages i have seen.. :)

    Oh Telerik Gurus, and wisdom to impart?
     

  12. Daniel
    Daniel avatar
    15 posts
    Member since:
    Jul 2013

    Posted 18 Jun 2014 in reply to Daniel Link to this post

    I was however able to get ads in all 3 platforms using Inneractive's JavaScript AdTag.
    https://inneractive.jira.com/wiki/display/DevWiki/JavaScript+Ad+Tag

    Here is my ads.js file.  I added the setInterval to make it refresh.
    setInterval("ia.rfAd();", 30000);
     
    try {
        (function () {
     
            console.log("GetInnerActiveAd() Start");
     
            if (typeof ia === 'undefined') {
                ia = {};
            }
     
            var ad_ios_key = 'GreaterVisions_DogeCoin_iPhone';
            var ad_android_key = 'GreaterVisions_DogeCoin_Android';
            var ad_winphone_key = 'GreaterVisions_DogeCoin_WP';
     
            console.log("UserAgent: " + navigator.userAgent);
     
            //default AD Key
            var adId = ad_winphone_key;
     
            if (navigator.userAgent.indexOf('Android') >= 0)
                adId = ad_android_key;
            if (navigator.userAgent.indexOf('iPhone') >= 0)
                adId = ad_ios_key;
            if (navigator.userAgent.indexOf('iPad') >= 0)
                adId = ad_ios_key;
     
            var width = screen.width;
            var height = screen.height;
     
     
            console.log("Ad Key: " + adId);
            console.log("Screen Height: " + height);
            console.log("Screen Width: " + width);
     
            // CHANGE AD SETTINGS BELOW.
            // More details about the different parameters can be found here:
            // https://inneractive.jira.com/wiki/display/DevWiki/JavaScript+Ad+Tag#JavaScriptAdTag-RequestParameters
            ia.adSettings = {
                APP_ID: adId,
                IS_MOBILE_WEB: false,
                IS_ORMMA_SUPPORT: false,
                IS_MRAID_SUPPORT: false,
                IS_VIDEO_SUPPORT: false,
                IS_FLOATING_BANNER: false,
                IS_INTERSTITIAL_AD: false,
                IMEI_MD5: '',
                IMEI_SHA1: '',
                IMSI_MD5: '',
                IMSI_SHA1: '',
                ANDROID_ID_MD5: '',
                ANDROID_ID_SHA1: '',
                IDFA: '',
                IDFV: '',
                PACKAGE_NAME: '', // In Android - The application name as a reverse domain notation string (e.g., 'com.inneractive.adTag'). In iOS - the App Store Id from the iTunes URL (e.g., "123456789" for the following iTunes link: 'https://itunes.apple.com/iw/app/myApp/id123456789?mt=8').
                CATEGORY: '', // e.g., Music
                AGE: '',
                GENDER: '',
                KEYWORDS: 'Finance,bitcoin,doge,dogecoin,money', // e.g., Rock,Pop,Jazz,Blues
                LOCATION: '',
                GPS_COORDINATES: '',
                DEVICE_WIDTH: width, // resolution width of the device
                DEVICE_HEIGHT: height, // resolution height of the device
                MOBILE_NETWORK_CODE: '',
                MOBILE_COUNTRY_CODE: '',
                NETWORK: '', // values are 3G or WIFI
                REQUIRED_WIDTH: '',
                REQUIRED_HEIGHT: '',
                FAILOVER: ''
            };
            console.log("Ad Done");
            // CHANGE AD SETTINGS  ABOVE.
        })();
    }
    catch (e) {
        console.log("AD failed: " + e.message);
    }


    I inserted the iaAdPlaceholder div in the footer section so it would show up right above the button bar. (I'm using the KendoUI layout)   
    <!--Layout-->
    <div data-role="layout" data-id="tabstrip-layout">
        <!--Header-->
        <div data-role="header">
            <div data-role="navbar">
                <span data-role="view-title"></span>
            </div>
        </div>
     
        <!--Footer-->
        <div data-role="footer">
            <div id='iaAdPlaceholder' class="OtherAd"></div>
            <div data-role="tabstrip">
                <a id="cmdHome" href="#/" data-icon="home">Home</a>
                <a href="#tabstrip-calculator" data-icon="compose">Calculator</a>
                <a href="#tabstrip-settings" data-icon="settings">Settings</a>
                <a href="#tabstrip-about" data-icon="about">About</a>
            </div>
        </div>
    </div>


    I added some CSS to deal with Android's button bar being at the top.
    .OtherAd {
        text-align: center;
        width: 100%;
    }
     
    .AndroidAd {
        position: fixed;
        bottom: 0;
        text-align: center;
        width: 100%;
    }

    And a quick script to toggle those CSS Classes in the deviceready code.
    if (device.platform == "Android") {
        $("#iaAdPlaceholder").addClass("AndroidAd").remove("OtherAd");
    }


    I am sure there are better ways of doing some of this, but it does work for me.. :)
  13. Alex
    Alex avatar
    54 posts
    Member since:
    Feb 2009

    Posted 18 Jun 2014 in reply to Jan-Dirk Link to this post

    I was using a real device, however I was using an AppBuilder Companion App on the real device. I missed that part, even though it was already stated that that does not work either.
    I got it working on the real device without the AppBuilder Companion App.

    It is actually very easy with the latest version of the plugin. I will write up the instructions in a separate post.
  14. Daniel
    Daniel avatar
    15 posts
    Member since:
    Jul 2013

    Posted 18 Jun 2014 in reply to Alex Link to this post

    You got it working with Windows Phone?  I am definitely interested to know your steps.. :)
  15. Alex
    Alex avatar
    54 posts
    Member since:
    Feb 2009

    Posted 18 Jun 2014 Link to this post

    Instructions for using the latest AdMob plugin:

    1. Download the following two cordova plugins as zip files (Use Download ZIP button)

    AdMob plugin at https://github.com/floatinghotpot/cordova-plugin-admob
    and
    Google Play Services plugin at https://github.com/MobileChromeApps/google-play-services

    Google Play Services is a dependency plugin for AdMob plugin 

    2. Create a new project in Telerik Platorm by selecting "AppBuilder Hybrid Project". I used just the "Blank (Javascript) template, but you can use any.

    3. In Project Navigator in Telerik Platform, right click on "Plugins" and select "Import Plugin" and repeat the procedure to import both zip files from step 1

    4. Expand "Plugins -> google-play-services-master" folder and open the "version.xml " file. Select and copy the version value inside this element <integer name="google_play_services_version">4452000</integer>

    5. Open the "plugin.xml" file in the same folder and replace "@integer/google_play_services_version" in <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> with the version value you copied, so it would look like this <meta-data android:name="com.google.android.gms.version" android:value="4452000" />

    6.  Expand "Plugins -> cordova-plugin-admob-master" folder, open the "plugin.xml" file and repeat the same procedure as in step 5, replacing the same element with the version value

    7. Expand the "test" folder in "Plugins -> cordova-plugin-admob-master" folder and copy the "index.html" over to the main "index.html" file in the root of the project, overwriting the existing file

    8. Open the "index.html" file in the root folder and replace the Android and iOS keys with your own

        var admob_ios_key = 'ca-app-pub-5555555555555/555555555555';
        var admob_android_key = 'ca-app-pub-5555555555555/555555555555';

    9. For Windows Phone 8, open the following file "Plugins -> cordova-plugin-admob-master -> src -> wp8 -> GoogleAds.XML" 
    Find the following element and replace the AdUnitId with your own

    <member name="P:GoogleAds.AdRequest.AdUnitId">
                <summary>
                ca-app-pub-5555555555555/555555555555
                </summary>
            </member>

    10. To test the app on real device, on Android for example, use "Run->Build->Android->App Package". Do not use Appbuilder, that does not work either in simulator or in AppBuilder Companion App on real device

    Enjoy
  16. Alex
    Alex avatar
    54 posts
    Member since:
    Feb 2009

    Posted 18 Jun 2014 Link to this post

    Note, I did not get it to build for Windows Phone 8.

    Telerik guys, please look into the build environment, there is something misconfigured there.
  17. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 20 Jun 2014 Link to this post

    Hi guys,

    @Alex I managed to reproduce the build error for Windows Phone. It seems like something in the WP sources of the plugin is messed up. However, we will further investigate this on our side and will let you know of the results.

    @Daniel thank you for sharing your solution on that matter with the community.

    Regards,
    Kaloyan
    Telerik
     

    Share what you think about AppBuilder and Telerik Platform with us in our feedback portal, so we can become even better!

     
  18. Daniel
    Daniel avatar
    15 posts
    Member since:
    Jul 2013

    Posted 25 Jun 2014 Link to this post

    Any update on the Windows Phone admob plugin not building?

  19. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 27 Jun 2014 Link to this post

    Hey guys,

    I am happy to share that the AdMob plugin is now build-able for WP8 inside AppBuilder. One of our developers contributed the needed change to the official plugin repository. It was immediately merged. So, please download the latest version of the plugin and check if it is working on your sides.

    Further, I have attached a demo project that should work well on WP8 devices. 

    I hope this helps.

    Regards,
    Kaloyan
    Telerik
     

    Share what you think about AppBuilder and Telerik Platform with us in our feedback portal, so we can become even better!

     
  20. Alex
    Alex avatar
    54 posts
    Member since:
    Feb 2009

    Posted 27 Jun 2014 Link to this post

    Great work Kaloyan and Telerik guys, thanks a lot
  21. Alex
    Alex avatar
    54 posts
    Member since:
    Feb 2009

    Posted 08 Sep 2014 Link to this post

    App Package build with latest AdMob plugin for iOS fails.
    I keep getting this:

    Failed to install 'com.rjfun.cordova.plugin.admob':Error: 404 Not Found: com.google.admobsdk-ios
    at RegClient.<anonymous> (/Users/builder/BpcTooling/Cordova3/3.5.0/node_modules/plugman/node_modules/npm/node_modules/npm-registry-client/lib/request.js:268:14)
    at Request.self.callback (/Users/builder/BpcTooling/Cordova3/3.5.0/node_modules/plugman/node_modules/npm/node_modules/request/index.js:148:22)
    at Request.EventEmitter.emit (events.js:98:17)
    at Request.<anonymous> (/Users/builder/BpcTooling/Cordova3/3.5.0/node_modules/plugman/node_modules/npm/node_modules/request/index.js:876:14)
    at Request.EventEmitter.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/Users/builder/BpcTooling/Cordova3/3.5.0/node_modules/plugman/node_modules/npm/node_modules/request/index.js:827:12)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:910:16
    at process._tickCallback (node.js:415:13)
    404 Not Found: com.google.admobsdk-ios




  22. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 11 Sep 2014 Link to this post

    Hello Alex,

    Thank you for reporting this. The failure was due to a bug on our server side, which we fixed right away.

    Please, check if everything is working as expected now and let us know if there are any further issues.

    Excuse us for any inconvenience this has caused.

    Regards,
    Kaloyan
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  23. Alex
    Alex avatar
    54 posts
    Member since:
    Feb 2009

    Posted 11 Sep 2014 in reply to Kaloyan Link to this post

    Perfect,
    thanks a lot Kaloyan
Back to Top