Intégration de Google Play Admob avec Phonegap
Comment ajouter Google Admob pour phonegap app (android) en 2014?
J'ai vérifié de nombreux exemples en ligne par exemple link1 link2 Link3 Link4. La plupart des lien vers Google sera bientôt obsolète Android 6.4.1 tutoriel.
En dehors de spécifique android ou iOS tutoriels, je ne trouve aucune qui montrent comment mettre en œuvre la dernière admob dans phonegap pour une croix-plate-forme app. J'ai vu inmobi cependant, il semble que vous devez publier votre application avant que vous pouvez obtenir un id d'éditeur pour vos annonces.
Mise à jour avec Android simplifié instructions
Je suis la boîte noire pour l'annonce mais rien d'autre, pas de messages d'alerte, aucune annonce
phonegap create myproject
cd mypproject
phonegap run android
Fermer l'émulateur
1.Install the Google Play Services plugin: cordova plugin add https://github.com/MobileChromeApps/google-play-services.git
2.Install this plugin: cordova plugin add https://github.com/floatinghotpot/cordova-plugin-admob.git
Puis je me dirigeais vers index.js et onDeviceReady j'ai ajouté
onDeviceReady: function() {
app.receivedEvent('deviceready');
if( window.plugins && window.plugins.AdMob ) {
var admob_android_key = 'pub-6xxxxxxxxxxxxx';
var am = window.plugins.AdMob;
am.createBannerView(
{
'publisherId': admob_android_key,
'adSize': am.AD_SIZE.BANNER,
'bannerAtTop': true
},
function() {
am.requestAd(
{ 'isTesting':true },
function(){
am.showAd( true );
},
function(){ alert('failed to request ad'); }
);
},
function(){ alert('failed to create banner view'); }
);
} else {
alert('AdMob plugin not available/ready.');
}
}
Ajouté index.html
<div>
<button id='show-ad' onClick="if(window.plugins.AdMob){ window.AdMob.plugins.showAd(true); }">Show Ad</button>
<button id='hide-ad' onClick="if(window.plugins.AdMob){ window.AdMob.plugins.showAd(false); }">Hide Ad</button>
</div>
phonegap exécuter android
source d'informationauteur Tom
Vous devez vous connecter pour publier un commentaire.
Ce admob plugin fonctionne avec google play sdk: https://github.com/floatinghotpot/cordova-plugin-admob . Vérifier les fichiers readme dans le dossier principal ET des sous-dossiers pour plus de détails.
Examen (2016). Afin de l'utiliser avec npm sources, si vous utilisez cordova version CLI, vous pouvez ajouter votre plugin avec:
Si vous êtes à l'intégration avec phonegap build, car ils ne prennent pas en charge gradle (en ce moment), vous devez ajouter cette balise dans votre config.xml:
Il y a des instructions d'installation et wiki ici
Voici un blog. De sorte que vous pouvez les annonces admob dans votre app Phonegap sans plugin.
http://phonegapguru.blogspot.in/2014/11/how-to-add-native-admob-ad-in.html?m=1