IONIC+Cordova+Metatag
Repo:
Beware that all the code and configuration cannot be considered production ready. It is merely example of integration approach described below.
https://github.com/mbrtargeting/mobile-sdk-cordova-example-app
Prerequisite:
STEP 1) AdMob Plus Plugin (detailed instructions: https://admob-plus.github.io/docs/cordova/installation )
in your Cordova app run
cordova plugin add admob-plus-cordova --save --variable APP_ID_ANDROID=ca-app-pub-xxx~xxx --variable APP_ID_IOS=ca-app-pub-xxx~xxx
STEP 2) AdMob Plus Cordova Webview Ad Plugin (detailed instructions https://admob-plus.github.io/docs/cordova/ads/webview )
first make sure you already installed AdMob Plus plugin
in your Cordova app run
cordova plugin add admob-plus-cordova-webview-ad --save
update the
config.xmlfor Android and IOS<preference name="Scheme" value="https" /> <preference name="Hostname" value="example.com" /> <preference name="AdMobPlusWebViewAd" value="true" /> <preference name="AdMobPlusOverrideUrlLoading" value="true" />Schema:
Android: https
IOS: httpsionic
Hostname:
your app hostname
Warning: If you use localStorage to storage data, please note that the previously data will not be accessible if you change the hostname to something else than previously used.
If ads are not displayed correctly (Probably on iOS), you may also need to add the following config to your
config.xml<allow-navigation href="*" />
Initiate admob in your code by running
document.addEventListener('deviceready', async () => { await admob.start(); });Example App: main.ts
If you experiencing performance issues on Android follow: https://admob-plus.github.io/docs/cordova/ads/webview#performance-issue-only-android
If you have strict CSP on your app follow: https://admob-plus.github.io/docs/cordova/ads/webview#content-security-policy-in-indexhtml
STEP 3) Metatag setup (detailed instructions https://stroeerdigitalgroup.atlassian.net/wiki/spaces/SDGPUBLIC/pages/51513328 )
make sure you have CMP set in your app
include metatag in your app
There are probably multiple approaches how to add metatag to your Angular app, this is one of them. Add metatag script in your
index.html(Example App: index.html)<script> window.SDG = window.SDG || {}; window.SDG.cmd = window.SDG.cmd || []; </script> <script async type="text/javascript" src="[your metatag script url]"></script>Depending on your TS setup you might want to add global type definitions in your
main.tsdeclare global { //Metatag currently does not offer type definitions. You might create your own based on //what you gonna use in your app or leave it as "any" interface Window { SDG: any; } var SDG: Window['SDG'] }
Usage
After all Prerequisite steps you should be able to register and load ad slots using Metatag as documented here: https://stroeerdigitalgroup.atlassian.net/wiki/spaces/SDGPUBLIC/pages/51513328/English+MetaTag+Documentation#PublisherApi%5BinlineExtension%5D
Example
Simple ad component for registering ads: Ad component
Usage of ad component and initiating ads loading: Ad component usage, Initiating ads loading