I know that there are bunch of answers here concerning PhoneGap. I've gone through all of them, and not a single solution worked. Even though, by all accounts, any one of them should. Many of the answers are so old that I doubt they are even valid anymore.
My app works, compiles, a runs fine. Except that I cannot get ads working. I tried AdMob first. Ads never show. So I said, "fine... I'll make my own instead." Which would be great if clicking on the ad resulted in opening a new browser. I thought a simple window.open() command would work. But, no. That doesn't happen. I need to use a cordova plugin to make that work.
I am using PhoneGap-Build on the Adobe site.
In my config.xml, I have:
<gap:plugin name="cordova-plugin-inappbrowser" spec="~3.0.0" source="npm" />
When I update the source I can see that the plugin is showing:
(from the PhoneGap page) Plugin Source Version Installed Platforms cordova-plugin-inappbrowser npm ~3.0.0 3.0.0 android,ios,winphone
After 30 or so tries with different variations of this, here is the JS code that I last tried:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
window.open = cordova.InAppBrowser.open;
}
function navToMobile(where){
var ref = cordova.InAppBrowser.open(where, '_system', 'location=yes');
navigator.app.loadUrl(where, { openExternal:true });
ref.show();
}
The function call for "navToMobile(where)" sends in a URL for 'where'.
There are 2 different methods in that function that should work, according to previous answers. I have them both there hoping just one of them would work...
When this runs, nothing happens. I installed the app on an emulator so I could see the log cat. That tells me that "cordova is not available". This says to me that the library is not being compiled into the app.
From what I gather, if I were doing this without "build PhoneGap", I would have a cordova.js library as part of my project. But I thought that is what the reference in the config.xml is for...
Anyway... I suspect that the exact same thing happens with AdMob. I set everything up according to the instructions, I created a new banner ad with an ID in AdMob... And the ads never show.
If anyone has any ideas how to get either one of these methods working, that would be great.
from PhoneGap Admob, external links... Can't get either one to work
0 komentar:
Posting Komentar