「Monaca/admob/admob-plus」の版間の差分
提供: 初心者エンジニアの簡易メモ
行2: | 行2: | ||
admob-freeの後継 | admob-freeの後継 | ||
− | == | + | ==インストール== |
https://github.com/admob-plus/admob-plus | https://github.com/admob-plus/admob-plus | ||
行17: | 行17: | ||
admob.banner.show({ // 18行目はここなので、admobがnullな様子。 | admob.banner.show({ // 18行目はここなので、admobがnullな様子。 | ||
+ | |||
+ | ==サンプル== | ||
+ | www/index.html | ||
+ | <pre> | ||
+ | <!DOCTYPE HTML> | ||
+ | <html> | ||
+ | <head> | ||
+ | <meta charset="utf-8"> | ||
+ | <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> | ||
+ | <meta http-equiv="Content-Security-Policy" content="default-src * data: gap: content: https://ssl.gstatic.com; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'"> | ||
+ | <script src="components/loader.js"></script> | ||
+ | <link rel="stylesheet" href="components/loader.css"> | ||
+ | <link rel="stylesheet" href="css/style.css"> | ||
+ | <script> | ||
+ | </script> | ||
+ | </head> | ||
+ | <body> | ||
+ | <br /> | ||
+ | This is a template for Monaca app. | ||
+ | <script> | ||
+ | document.addEventListener('deviceready', () => { | ||
+ | admob.banner.show({ | ||
+ | id: { | ||
+ | // replace with your ad unit IDs | ||
+ | android: 'ca-app-pub-3940256099942544/6300978111', | ||
+ | ios: 'ca-app-pub-3940256099942544/2934735716', | ||
+ | }, | ||
+ | }).then(() => { | ||
+ | setTimeout(() => { | ||
+ | admob.banner.hide({ | ||
+ | // replace with your ad unit IDs | ||
+ | android: 'ca-app-pub-3940256099942544/6300978111', | ||
+ | ios: 'ca-app-pub-3940256099942544/2934735716', | ||
+ | }) | ||
+ | }, 10000) | ||
+ | }) | ||
+ | }, false) | ||
+ | </script> | ||
+ | </body> | ||
+ | </html> | ||
+ | </pre> | ||
+ | 上記ca-app-pub-はadmobの公式サンプルのもの |
2020年5月26日 (火) 16:54時点における版
admob-plusとは
admob-freeの後継
インストール
https://github.com/admob-plus/admob-plus
インストール方法
公式:https://admob-plus.github.io/docs/installation.html
cordova plugin add cordova-admob-plus --variable APP_ID_ANDROID=ca-app-pub-xxx~xxx --variable APP_ID_IOS=ca-app-pub-xxx~xxx
cordova plugin add cordova-plugin-androidx cordova plugin add cordova-plugin-androidx-adapter
admobが無いエラー
Uncaught ReferenceError: admob is not defined www/index.html:18
admob.banner.show({ // 18行目はここなので、admobがnullな様子。
サンプル
www/index.html
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <meta http-equiv="Content-Security-Policy" content="default-src * data: gap: content: https://ssl.gstatic.com; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'"> <script src="components/loader.js"></script> <link rel="stylesheet" href="components/loader.css"> <link rel="stylesheet" href="css/style.css"> <script> </script> </head> <body> <br /> This is a template for Monaca app. <script> document.addEventListener('deviceready', () => { admob.banner.show({ id: { // replace with your ad unit IDs android: 'ca-app-pub-3940256099942544/6300978111', ios: 'ca-app-pub-3940256099942544/2934735716', }, }).then(() => { setTimeout(() => { admob.banner.hide({ // replace with your ad unit IDs android: 'ca-app-pub-3940256099942544/6300978111', ios: 'ca-app-pub-3940256099942544/2934735716', }) }, 10000) }) }, false) </script> </body> </html>
上記ca-app-pub-はadmobの公式サンプルのもの