├── .gitignore
├── .vscode
└── settings.json
├── .watchmanconfig
├── App.js
├── README.md
├── app.json
├── assets
├── icon.png
└── splash.png
├── babel.config.js
├── demo.png
├── package.json
└── yarn.lock
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/**/*
2 | .expo/*
3 | npm-debug.*
4 | *.jks
5 | *.p12
6 | *.key
7 | *.mobileprovision
8 | .DS_Store
9 |
10 | # Logs
11 | logs
12 | *.log
13 | npm-debug.log*
14 | yarn-debug.log*
15 | yarn-error.log*
16 |
17 | # Runtime data
18 | pids
19 | *.pid
20 | *.seed
21 | *.pid.lock
22 |
23 | # Directory for instrumented libs generated by jscoverage/JSCover
24 | lib-cov
25 |
26 | # Coverage directory used by tools like istanbul
27 | coverage
28 |
29 | # nyc test coverage
30 | .nyc_output
31 |
32 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
33 | .grunt
34 |
35 | # Bower dependency directory (https://bower.io/)
36 | bower_components
37 |
38 | # node-waf configuration
39 | .lock-wscript
40 |
41 | # Compiled binary addons (https://nodejs.org/api/addons.html)
42 | build/Release
43 |
44 | # Dependency directories
45 | node_modules/
46 | jspm_packages/
47 |
48 | # TypeScript v1 declaration files
49 | typings/
50 |
51 | # Optional npm cache directory
52 | .npm
53 |
54 | # Optional eslint cache
55 | .eslintcache
56 |
57 | # Optional REPL history
58 | .node_repl_history
59 |
60 | # Output of 'npm pack'
61 | *.tgz
62 |
63 | # Yarn Integrity file
64 | .yarn-integrity
65 |
66 | # dotenv environment variables file
67 | .env
68 | .env.test
69 |
70 | # parcel-bundler cache (https://parceljs.org/)
71 | .cache
72 |
73 | # next.js build output
74 | .next
75 |
76 | # nuxt.js build output
77 | .nuxt
78 |
79 | # vuepress build output
80 | .vuepress/dist
81 |
82 | # Serverless directories
83 | .serverless/
84 |
85 | # FuseBox cache
86 | .fusebox/
87 |
88 | # DynamoDB Local files
89 | .dynamodb/
90 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "files.exclude": {
3 | "**/.git": true,
4 | "**/.svn": true,
5 | "**/.hg": true,
6 | "**/CVS": true,
7 | "**/.DS_Store": true,
8 | "**/node_modules": true,
9 | "**/dist/**": true
10 | },
11 | "workbench.colorCustomizations": {
12 | "titleBar.activeBackground": "#9317dbf6",
13 | "titleBar.inactiveBackground": "#b44bf1cc",
14 | "titleBar.activeForeground": "#ffffff"
15 | },
16 | "typescript.tsdk": "node_modules/typescript/lib"
17 | }
18 |
--------------------------------------------------------------------------------
/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/App.js:
--------------------------------------------------------------------------------
1 | import {
2 | AdMobBanner,
3 | AdMobInterstitial,
4 | AdMobRewarded,
5 | PublisherBanner,
6 | } from 'expo'
7 | import React, { Component } from 'react'
8 | import { SafeAreaView, ScrollView } from 'react-native'
9 | import { Button, Text } from 'react-native-elements'
10 | console.disableYellowBox = true
11 |
12 | AdMobInterstitial.setAdUnitID(INTERSTITIAL_ID)
13 | AdMobInterstitial.setTestDeviceID('EMULATOR')
14 | AdMobRewarded.setAdUnitID(REWARDED_ID)
15 | AdMobRewarded.setTestDeviceID('EMULATOR')
16 |
17 | class App extends Component {
18 | state = {
19 | disableInterstitialBtn: false,
20 | disableRewardedBtn: false,
21 | }
22 |
23 | _openInterstitial = async () => {
24 | try {
25 | this.setState({ disableInterstitialBtn: true })
26 | await AdMobInterstitial.requestAdAsync()
27 | await AdMobInterstitial.showAdAsync()
28 | } catch (error) {
29 | console.error(error)
30 | } finally {
31 | this.setState({ disableInterstitialBtn: false })
32 | }
33 | }
34 |
35 | _openRewarded = async () => {
36 | try {
37 | this.setState({ disableRewardedBtn: true })
38 | await AdMobRewarded.requestAdAsync()
39 | await AdMobRewarded.showAdAsync()
40 | } catch (error) {
41 | console.error(error)
42 | } finally {
43 | this.setState({ disableRewardedBtn: false })
44 | }
45 | }
46 |
47 | render() {
48 | const { disableInterstitialBtn, disableRewardedBtn } = this.state
49 | return (
50 |
51 |
52 | GOOGLE ADMOB DEMO
53 |
54 | Set Ad Unit Id, Interstitial Id & Rewarded Id only on the top level
55 | component once.
56 |
57 | Banner Ad
58 |
59 | Publisher Banner
60 |
61 | Interstitial Ad
62 |
68 | Rewarded Ad
69 |
75 |
76 |
77 | )
78 | }
79 | }
80 |
81 | export default App
82 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # expo-google-admob
2 |
3 | > Use Google Admob in combination with Expo to monetise your app
4 |
5 |
6 |
7 | Check [the demo on Expo](https://expo.io/@deadcoder0904/expo-google-admob)
8 |
9 | # Clone the repo
10 |
11 | ```bash
12 | $ git clone git@github.com:deadcoder0904/expo-google-admob.git
13 | ```
14 |
15 | # Install the dependencies
16 |
17 | ```bash
18 | $ yarn
19 | ```
20 |
21 | # Run the app
22 |
23 | ```bash
24 | $ yarn start
25 | ```
26 |
27 | # License
28 |
29 | MIT © [Akshay Kadam](https://twitter.com/deadcoder0904)
30 |
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "expo": {
3 | "name": "expo-google-admob",
4 | "slug": "expo-google-admob",
5 | "privacy": "public",
6 | "sdkVersion": "32.0.0",
7 | "platforms": [
8 | "ios",
9 | "android"
10 | ],
11 | "version": "1.0.0",
12 | "orientation": "portrait",
13 | "icon": "./assets/icon.png",
14 | "splash": {
15 | "image": "./assets/splash.png",
16 | "resizeMode": "contain",
17 | "backgroundColor": "#ffffff"
18 | },
19 | "updates": {
20 | "fallbackToCacheTimeout": 0
21 | },
22 | "assetBundlePatterns": [
23 | "**/*"
24 | ],
25 | "ios": {
26 | "supportsTablet": true
27 | },
28 | "description": "Google Admob Working Example using Expo wrapper around `react-native-admob` 🛠️",
29 | "githubUrl": "https://github.com/deadcoder0904/expo-google-admob"
30 | }
31 | }
--------------------------------------------------------------------------------
/assets/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deadcoder0904/expo-google-admob/3a87e5983d8963f8e2283d74120a226a0d4f26c5/assets/icon.png
--------------------------------------------------------------------------------
/assets/splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deadcoder0904/expo-google-admob/3a87e5983d8963f8e2283d74120a226a0d4f26c5/assets/splash.png
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = function(api) {
2 | api.cache(true);
3 | return {
4 | presets: ['babel-preset-expo'],
5 | };
6 | };
7 |
--------------------------------------------------------------------------------
/demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deadcoder0904/expo-google-admob/3a87e5983d8963f8e2283d74120a226a0d4f26c5/demo.png
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "main": "node_modules/expo/AppEntry.js",
3 | "scripts": {
4 | "start": "expo start",
5 | "android": "expo start --android",
6 | "ios": "expo start --ios",
7 | "eject": "expo eject"
8 | },
9 | "dependencies": {
10 | "expo": "^32.0.6",
11 | "react": "16.8.6",
12 | "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
13 | "react-native-elements": "^1.1.0"
14 | },
15 | "devDependencies": {
16 | "babel-preset-expo": "^5.1.1"
17 | },
18 | "private": true
19 | }
20 |
--------------------------------------------------------------------------------