开发者

admob for webos/palm

i want integrate admob ads to my palm开发者_Go百科 pre application.can you please suggest me and share integration code for ads.some where i found code it wont work for me

Thanks in Advance

Aswan


First, make an account at admob. Create a new app Go to "sites and apps" and click "add site/app" Fill out the information. Once you are done, you should be able to go to the "sites and app" tab and click "sites and apps". This brings up a list of all your apps. Hover over the app you just filled out and click "manage settings". There, you should find your publisher ID. Save it. You will need it later.

Then, download the admob.js file at this link

In your sources.json file add {"source": "app/admob.js"}

Make sure the path is where your admob.js files is located at. In this case, its in my /app folder.

Then, go to the setup() function of the scene where you want to display the ad. Add the following code: AdMob.ad.initialize({ pub_id: 'aaaaaaaaaaaaaa', bg_color: '#ccc', text_color: '#333', test_mode: true });

Replace the pub_id parameter with your publisher ID from the first step. The colors should be self explanatory. When you are setting up your ads, have test_mode to true. TURN IT OFF BEFORE YOU SHIP YOUR APP.

Then, go to the view file of the scene where you want the add. Add a . Call it "admob_ad"

<div id = "admob_ad"></div>

Now, the final step. Call this to actually make the request:

AdMob.ad.request({
            onSuccess: (function (ad) { 
                    this.controller.get('admob_ad').insert(ad); 
            }).bind(this),
            onFailure: (function () { 

            }).bind(this),

    });

Now, usually you will will make the ad request in your setup method, as you will only load an app when the scene loads. Admob has rules as to how often you should refresh ads, so be careful.

Now, when you run this, you should get one of those admob banners that says something like "admob test messages". Once you have it working and are ready to ship your app, turn off test_mode in your setup call. Keep in mind that once you do this, the ad will not be filled 100% of the time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜