Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Cross Platform Ads

Hi there,

I have built my iPhone app, and all is well. I have integrated AdMob into it using a plug-in I have found and that works well.

I'm trying to make the app multi-platform so that it will run on Android, and Blackberry (once support is added).

Does anyone have some example code for integrating ads on both platforms easily? It doesn't have to be AdMob (although I do love that network), but it does need to be the same Ad network for both platforms.

I currently have the following, which doesn't work:

if (Ti.Platform.name == "android"){

    var adProvider = Titanium.AdManager.createProvider({
        type: "AdMob", // Extendable - allows dynamic location of new ad providers
        properties:{
            publisherID:'a14c8e844729563', // Put your publisher ID here from AdMob
            useLocation:true, 
            devMode: [Titanium.AdManager.AdMob.TEST_EMULATOR, 'something']
        }
    });

    // Create the Ad itself
    var admob = adProvider.createAd({
        left:0,
        bottom:0, 
        width:Titanium.Platform.displayCaps.platformWidth, 
        zIndex:1,
        refreshInterval:30
    });

} else {

    var Ad = require('jp.masuidrive.ti.admob');
    var admob = Ad.createAdMob({
        test: false,
        publisher: "a14c8e844729563", // required
        //top: ( 460 - 48 ) / 2,
        bottom:0,
        left: 0,
        width: 320, // required
        height: 48, // required
        backgroundColor: "#ffffff",
        adBackgroundColor: "#ffffff",
        primaryTextColor: "#000000",
        secondaryTextColor: "#000000",
        refresh: 30.0
    });

}

This errors because Titanium.AdManager doesn't exist. I think I haven't linked the library in correctly, if at all. I'm looking for an alternative solution, working code, or a fix. Hope someone can help :)

Thanks

— asked December 4th 2010 by Mike Griffiths
  • admob
  • advertising
  • iphone
0 Comments

2 Answers

  • Clean your build folders for iphone and android and build it again.

    — answered December 4th 2010 by Mario Müller
    permalink
    1 Comment
    • still the same

      — commented December 8th 2010 by Mike Griffiths
  • care to share your admob plugin?

    — answered December 4th 2010 by danno watts
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.