[英]Interstatial Admob using PhoneGap not working
I'm trying to display interstitial Ad in my PhoneGap app but it's not working; 我试图在我的PhoneGap应用中显示插页式广告,但它不起作用; it's not displaying the ad at all.
它根本不显示广告。 I followed the instructions here .
我按照这里的指示进行。
Apart from trying to make it work, what I also need to do is to show the interstitial at a particular time (probably when the game is over) but I dont know how to refer to the Java code from JavaScript code to show the loaded interstitial ad. 除了尝试使其正常工作外,我还需要做的是在特定时间显示插页式广告(可能是在游戏结束时),但是我不知道如何从JavaScript代码中引用Java代码来显示已加载的插页式广告广告。
Please help. 请帮忙。
I recently got AdMob working within my Cordova 4 project after much fiddling. 经过多次摆弄之后,我最近在AdMob的Cordova 4项目中工作了。 Forget the instructions you linked to in your question, which are not for cordova/phonegap builds.
忘记您在问题中链接的说明,这些说明不适用于cordova / phonegap构建。
Step 1 : You will need to install the Cordova/Phonegap plugin for Admob. 第1步 :您将需要为Admob安装Cordova / Phonegap插件。 (This assumes you have already created the project files .) In my case, eg for Cordova command line interface, I used Terminal,
cd
to my project's root directory and then type: (这假设您已经创建了项目文件 。)就我而言,例如对于Cordova命令行界面,我使用Terminal,
cd
到项目的根目录,然后键入:
cordova plugin add com.admob.google
For your Phonegap setup, you will likely need to do one of the following : 对于Phonegap设置,您可能需要执行以下操作之一 :
Add this to your project's config.xml file. 将此添加到项目的config.xml文件中。
<gap:plugin name="com.admob.google" source="plugins.cordova.io" />
OR (for Phonegap CLI), type this command into Terminal from your project's root directory, 或 (对于Phonegap CLI),从项目的根目录将此命令键入Terminal,
phonegap local plugin add com.admob.google
Once you have the plugin, you can use javascript to control Admob behavior. 有了插件后,您就可以使用JavaScript来控制Admob行为。
Step 2 : Add appropriate javascript for Admob plugin to your project, linked in your index.html file. 第2步 :将适合Admob插件的JavaScript添加到您的项目中,并链接到index.html文件。 I ran into some trouble here, so just to prove to myself that the plugin really works, I removed (backed up) everything from my project's WWW folder and added the exact files from the WWW folder from this project and later this one on Github.
我遇到了一些麻烦,在这里,所以只是为了证明自己的插件确实有效,我删除(备份)从我的项目的WWW文件夹中的一切,从增加从WWW文件夹中的确切文件, 这个项目后来这个 Github上。 Both work.
两者都可以。 It was then a matter of making smarter-people-than-myself's javascript work in my app.
这就是在我的应用程序中使比我更聪明的人的javascript工作的问题。
A few tips 一些技巧
<script type="text/javascript" src="cordova.js"></script>
in your head of your index file. <script type="text/javascript" src="cordova.js"></script>
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.