Permalink
Browse files

add admob support

  • Loading branch information...
shprink committed Dec 28, 2017
1 parent 39278e8 commit 4abdf6741e42bf3460e2c7048fd7b729a36169c2
Showing with 79 additions and 25 deletions.
  1. +2 −2 README.md
  2. +9 −1 dist/config/config.cson
  3. +2 −0 dist/config/index.ts
  4. +9 −4 dist/root/config.xml
  5. +5 −3 package.json
  6. +12 −13 src/config.default.cson
  7. +1 −0 src/providers/config.ts
  8. +31 −2 src/providers/native/native.ts
  9. +8 −0 yarn.lock
View
@@ -22,10 +22,10 @@
- [X] Syntax highlighter
- [X] Social sharing
- [X] Docker build
- [X] Admob support
- [ ] App rate plugin
- [ ] Comments
- [ ] Push Notifications
- [ ] Admob support
- [ ] App rate plugin
- [ ] Login via JWT
## Sponsors
View
@@ -20,4 +20,12 @@ metas:
ogImageHeight: 400
# Twitter card
twitterSite: ''
twitterCreator: '' # e.g @julienrenaux
twitterCreator: '' # e.g @julienrenaux
admob:
bannerEnabled: false
interstitialEnabled: false
config:
publisherId: null
interstitialAdId: null
isTesting: true
View
@@ -10,6 +10,7 @@ import { SplashScreen } from '@ionic-native/splash-screen';
import { Push } from '@ionic-native/push';
import { Toast } from '@ionic-native/toast';
import { SocialSharing } from '@ionic-native/social-sharing';
import { AdMobFree } from '@ionic-native/admob-free';
import { Storage } from '@ionic/storage';
import { MomentModule } from 'angular2-moment';
@@ -94,6 +95,7 @@ export function appInitializerTranslateFactory(translate: TranslateService, inje
Push,
Toast,
SocialSharing,
AdMobFree,
{ provide: Storage, useFactory: provideStorage },
// { provide: Settings, useFactory: provideSettings, deps: [ Storage ] },
// Keep this to enable Ionic's runtime error handling during development
View
@@ -22,6 +22,7 @@
<preference name="FadeSplashScreenDuration" value="300" />
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="SplashScreen" value="screen" />
<preference name="LoadUrlTimeoutValue" value="60000"/>
<preference name="android-minSdkVersion" value="17" />
<preference name="android-targetSdkVersion" value="17" />
<feature name="StatusBar">
@@ -30,9 +31,6 @@
<resources>
<integer name="google_play_services_version">5089000</integer>
</resources>
<plugin name="phonegap-plugin-push" spec="~1.6.0">
<param name="SENDER_ID" value="XXXXXXX" />
</plugin>
<hook src="scripts/nativeBeforeBuild.js" type="after_platform_add" />
<preference name="CrosswalkAnimatable" value="true" />
<platform name="android">
@@ -113,6 +111,13 @@
<plugin name="cordova-plugin-crosswalk-webview" spec="~2.3.0" />
<plugin name="cordova-plugin-wkwebview-engine" spec="~1.1.2" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.2" />
<engine name="android" spec="~6.1.2" />
<engine name="android" spec="~6.3.0" />
<plugin name="cordova-plugin-x-socialsharing" spec="~5.2.1" />
<plugin name="cordova-plugin-admob-free" spec="~0.13.0" />
<plugin name="cordova-android-play-services-gradle-release" spec="~1.1.4">
<variable name="PLAY_SERVICES_VERSION" value="11.+" />
</plugin>
<plugin name="phonegap-plugin-push" spec="~1.6.0">
<param name="SENDER_ID" value="XXXXXXX" />
</plugin>
</widget>
View
@@ -33,8 +33,8 @@
"ionic:build": "ionic build",
"ionic:requirements": "ionic cordova requirements",
"clean": "ionic-app-scripts clean",
"run:android": "ionic build && npm run ionic:run android",
"run:ios": "ionic build && npm run ionic:run ios",
"run:android": "ionic build && npm run ionic:run android --livereload",
"run:ios": "ionic build && npm run ionic:run ios --livereload",
"build:dev": "./scripts/buildPWA.sh",
"build:pwa": "./scripts/buildPWA.sh",
"buildAndRun:pwa": "./scripts/buildPWAAndRun.sh",
@@ -56,6 +56,7 @@
"@angular/platform-browser-dynamic": "4.4.4",
"@angular/platform-server": "4.4.4",
"@angular/service-worker": "^1.0.0-beta.15",
"@ionic-native/admob-free": "^4.5.2",
"@ionic-native/core": "^3.4.2",
"@ionic-native/push": "^3.4.2",
"@ionic-native/social-sharing": "^4.4.2",
@@ -69,6 +70,7 @@
"@ngrx/store-devtools": "^3.2.2",
"@ngx-translate/core": "^6.0.1",
"@ngx-translate/http-loader": "^0.0.3",
"android-versions": "^1.2.1",
"angular2-moment": "^1.1.0",
"clipboard": "^1.7.1",
"debug": "^2.6.8",
@@ -131,4 +133,4 @@
"ionic_copy": "./build/copy.js",
"ionic_watch": "./build/watch.js"
}
}
}
View
@@ -119,16 +119,15 @@ statusBar:
style: 'default' # 'default' | 'light' | 'blackTranslucent' | 'blackOpaque' # http://ionicframework.com/docs/native/status-bar/
admob:
enabled: false
android:
bannerID: null
bannerPosition: 'BOTTOM_CENTER'
interstitialID: null
ios:
bannerID: null
bannerPosition: 'BOTTOM_CENTER'
interstitialID: null
windows:
bannerID: null
bannerPosition: 'BOTTOM_CENTER'
interstitialID: null
bannerEnabled: false
interstitialEnabled: false
config:
publisherId: null
interstitialAdId: null
bannerAtTop: false
overlap: false
offsetTopBar: false
isTesting: false
autoShow: true
forChild: null
forFamily: null
View
@@ -37,4 +37,5 @@ export class Config {
// Native
getPushNotifications = (path = '', otherwise = undefined) => this.get(`pushNotifications.${path}`, otherwise);
getStatusBar = (path = '', otherwise = undefined) => this.get(`statusBar.${path}`, otherwise);
getAdMob = (path = '', otherwise = undefined) => this.get(`admob.${path}`, otherwise);
}
@@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import debug from 'debug';
import { StatusBar } from '@ionic-native/status-bar';
import { AdMobFree, AdMobFreeBannerConfig } from '@ionic-native/admob-free';
import { Config } from '../config';
@@ -16,12 +17,14 @@ const log = debug('Native');
export class NativeProvider {
constructor(
public config: Config,
public statusBar: StatusBar,
private config: Config,
private statusBar: StatusBar,
private admobFree: AdMobFree,
) { }
init() {
this.statusBarInit();
this.addMobInit();
}
statusBarInit() {
@@ -47,4 +50,30 @@ export class NativeProvider {
}
}
addMobInit() {
const bannerEnabled: boolean = this.config.getAdMob('bannerEnabled', false);
const interstitialEnabled: boolean = this.config.getAdMob('interstitialEnabled', false);
const config: AdMobFreeBannerConfig = this.config.getAdMob('config', {});
log('addMob bannerEnabled', bannerEnabled);
log('addMob interstitialEnabled', interstitialEnabled);
log('addMob config', config);
if (bannerEnabled) {
this.admobFree.banner.config(config);
this.admobFree.banner.prepare()
.then(() => log('addMob banner ready'))
.catch(error => log('addMob banner error', error));
}
if (interstitialEnabled) {
this.admobFree.interstitial.config(config);
this.admobFree.interstitial.prepare()
.then(() => log('addMob interstitial ready'))
.catch(error => log('addMob interstitial error', error));
}
}
}
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 4abdf67

Please sign in to comment.