Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 37c854c

Browse files
EddyVerbruggeneddyverbruggen
authored andcommitted
#19 Conflict with nativescript-admob
#55 Support for AdMob #85 Google Service conflits on using nativescript-admob with this plugin #284 nativescript-plugin-firebase and nativescript admob conflict
1 parent 63270fe commit 37c854c

File tree

7 files changed

+166
-39
lines changed

7 files changed

+166
-39
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<img src="docs/images/firebase-logo.png" width="116px" height="32px" alt="Firebase"/>
22

3+
SDK's updated!
34

45
## 3.9.4 (2017, February 15)
56

README.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,10 @@ firebase.init({
138138
```
139139

140140
#### Pod dependency error
141-
If you see an error like `Unable to satisfy the following requirements: Firebase (~> 3.3.0) required by Podfile`,
142-
then check [issue 98](#98) which perfectly explains how to update your local Pod spec repo, or first try
143-
to `tns platform remove ios && tns platform add ios`.
141+
If you see an error like `Unable to satisfy the following requirements: Firebase (~> 3.13.0) required by Podfile`,
142+
then run `pod repo update` on the command line to make sure you have the latest Podspec.
144143

145-
Running `pod repo update` on the command line will make sure you have the latest Podspec,
146-
so when the plugin updates and a newer Firebase version can't be found, try that first.
144+
This could happen when updating the plugin to a new version. You'll want to `tns platform remove ios && tns platform add ios` as well to clean out the old pod version.
147145

148146
## Known issues on Android
149147

@@ -198,10 +196,9 @@ Another possible error is "FirebaseApp with name [DEFAULT] doesn't exist." which
198196
placing `google-services.json` to `platforms/android/google-services.json` (see above), and making
199197
the changes to `build.gradle` which are mentioned above as well.
200198

201-
#### Could not find com.google...
202-
And there's this one: "Could not find com.google.firebase:firebase-auth:10.0.+". That means
203-
making sure you have the latest `Google Repository` bits installed.
204-
Just run `android` from a command prompt and install any pending updates.
199+
#### Could not find any version that matches com.google.android.gms:play-services-auth:10.2.+.
200+
That means making sure you have the latest `Google Repository` bits installed.
201+
Just run `android` from a command prompt, expand `Extras` and install any pending updates.
205202

206203
Also, an error like "Could not find com.google.firebase:firebase-core:10.0.0" can be caused by having
207204
more than one version of the Android SDK installed. Make sure ANDROID_HOME is set to the Android SDK directory

docs/ADMOB.md

Lines changed: 106 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,111 @@
33
<img src="images/features/admob.png" width="296px" height="124px" alt="admob"/>
44

55
## Enabling AdMob
6-
Since plugin version 3... you can use Firebase _AdMob_ features.
6+
Since plugin version 3.10.0 you can use Firebase _AdMob_ features.
77

8-
_AdMob_ lets you ..
8+
_AdMob_ lets you show banners or interstitials (full screen ads) in your app so you can earn a little money.
99

10-
WORK IN PROGRESS.. updating right now (Feb 17, 2017)
10+
### iOS
11+
12+
#### App Transport Security
13+
Open `app/App_Resources/iOS/Info.plist` and add this to the bottom:
14+
15+
```xml
16+
<key>NSAppTransportSecurity</key>
17+
<dict>
18+
<key>NSAllowsArbitraryLoads</key>
19+
<true/>
20+
<key>NSAllowsArbitraryLoadsForMedia</key>
21+
<true/>
22+
<key>NSAllowsArbitraryLoadsInWebContent</key>
23+
<true/>
24+
</dict>
25+
```
26+
27+
[More info on this subject.](https://firebase.google.com/docs/admob/ios/app-transport-security)
28+
29+
## Functions
30+
31+
### admob.showBanner
32+
Go [manage your AdMob app](https://apps.admob.com/#account/appmgmt:) and grab the banner, then show it in your app:
33+
34+
```js
35+
firebase.admob.showBanner({
36+
size: firebase.admob.AD_SIZE.SMART_BANNER, // see firebase.admob.AD_SIZE for all options
37+
margins: { // optional nr of device independent pixels from the top or bottom (don't set both)
38+
bottom: 10,
39+
top: 0
40+
},
41+
androidBannerId: "ca-app-pub-9517346003011652/7749101329",
42+
iosBannerId: "ca-app-pub-9517346003011652/3985369721",
43+
testing: true, // when not running in production set this to true, Google doesn't like it any other way
44+
iosTestDeviceIds: [ //Android automatically adds the connected device as test device with testing:true, iOS does not
45+
"45d77bf513dfabc2949ba053da83c0c7b7e87715", // Eddy's iPhone 6s
46+
"fee4cf319a242eab4701543e4c16db89c722731f" // Eddy's iPad Pro
47+
]
48+
}).then(
49+
function () {
50+
console.log("AdMob banner showing");
51+
},
52+
function (errorMessage) {
53+
dialogs.alert({
54+
title: "AdMob error",
55+
message: errorMessage,
56+
okButtonText: "Hmmkay"
57+
});
58+
}
59+
);
60+
```
61+
62+
### admob.hideBanner
63+
Easy peasy:
64+
65+
```js
66+
firebase.admob.hideBanner().then(
67+
function () {
68+
console.log("AdMob banner hidden");
69+
},
70+
function (errorMessage) {
71+
dialogs.alert({
72+
title: "AdMob error",
73+
message: errorMessage,
74+
okButtonText: "Hmmkay"
75+
});
76+
}
77+
);
78+
```
79+
80+
### admob.showInterstitial
81+
This is a fullscreen ad, so you can earn extra credit on the eternal ladder of annoyance.
82+
83+
Note that an interstitial is supposed to be hidden by clicking the close button, so there's no function to do it programmatically.
84+
85+
```js
86+
firebase.admob.showInterstitial({
87+
iosInterstitialId: "ca-app-pub-9517346003011652/6938836122",
88+
androidInterstitialId: "ca-app-pub-9517346003011652/6938836122",
89+
testing: true, // when not running in production set this to true, Google doesn't like it any other way
90+
iosTestDeviceIds: [ // Android automatically adds the connected device as test device with testing:true, iOS does not
91+
"45d77bf513dfabc2949ba053da83c0c7b7e87715", // Eddy's iPhone 6s
92+
"fee4cf319a242eab4701543e4c16db89c722731f" // Eddy's iPad Pro
93+
]
94+
}).then(
95+
function () {
96+
console.log("AdMob interstitial showing");
97+
},
98+
function (errorMessage) {
99+
dialogs.alert({
100+
title: "AdMob error",
101+
message: errorMessage,
102+
okButtonText: "Hmmkay"
103+
});
104+
}
105+
);
106+
```
107+
108+
## What about the nativescript-admob plugin?
109+
There's currently no functional difference between the AdMob features in the Firebase plugin and
110+
[nativescript-admob](https://github.com/EddyVerbruggen/nativescript-admob).
111+
112+
The main advantage of using the version in the Firebase plugin is to avoid a gradle build conflict
113+
in the Android build you may encounter when including both plugins in your app.

platforms/android/include.gradle

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,28 @@ repositories {
1414

1515
dependencies {
1616
// make sure you have these versions by updating your local Android SDK's (Android Support repo and Google repo)
17-
compile "com.google.firebase:firebase-core:10.0.+"
18-
compile "com.google.firebase:firebase-database:10.0.+"
19-
compile "com.google.firebase:firebase-auth:10.0.+"
17+
compile "com.google.firebase:firebase-core:10.2.+"
18+
compile "com.google.firebase:firebase-database:10.2.+"
19+
compile "com.google.firebase:firebase-auth:10.2.+"
2020

2121
// for reading google-services.json and configuration
22-
def googlePlayServicesVersion = project.hasProperty('googlePlayServicesVersion') ? project.googlePlayServicesVersion : '10.0.+'
22+
def googlePlayServicesVersion = project.hasProperty('googlePlayServicesVersion') ? project.googlePlayServicesVersion : '10.2.+'
2323
compile "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
2424

2525
// Uncomment if you want to use 'Remote Config'
26-
// compile "com.google.firebase:firebase-config:10.0.+"
26+
// compile "com.google.firebase:firebase-config:10.2.+"
2727

2828
// Uncomment if you want to use 'Crash Reporting'
29-
// compile "com.google.firebase:firebase-crash:10.0.+"
29+
// compile "com.google.firebase:firebase-crash:10.2.+"
3030

3131
// Uncomment if you want FCM (Firebase Cloud Messaging)
32-
// compile "com.google.firebase:firebase-messaging:10.0.+"
32+
// compile "com.google.firebase:firebase-messaging:10.2.+"
3333

3434
// Uncomment if you want Google Cloud Storage
35-
// compile 'com.google.firebase:firebase-storage:10.0.+'
35+
// compile 'com.google.firebase:firebase-storage:10.2.+'
36+
37+
// Uncomment if you want AdMob
38+
// compile 'com.google.firebase:firebase-ads:10.2.+'
3639

3740
// Uncomment if you need Facebook Authentication
3841
// compile "com.facebook.android:facebook-android-sdk:4.+"

platforms/ios/Podfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
pod 'Firebase', '~> 3.11.0'
2+
pod 'Firebase', '~> 3.13.0'
33
pod 'Firebase/Database'
44
pod 'Firebase/Auth'
55

@@ -15,6 +15,9 @@ pod 'Firebase/Auth'
1515
# Uncomment if you want to enable Firebase Storage
1616
#pod 'Firebase/Storage'
1717

18+
# Uncomment if you want to enable AdMob
19+
#pod 'Firebase/AdMob'
20+
1821
# Uncomment if you want to enable Facebook Authentication
1922
#pod 'FBSDKCoreKit'
2023
#pod 'FBSDKLoginKit'

scripts/installer.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ function promptQuestions() {
139139
name: 'google_auth',
140140
description: 'Are you using Firebase Google Authentication (y/n)',
141141
default: 'n'
142+
}, {
143+
name: 'admob',
144+
description: 'Are you using AdMob (y/n)',
145+
default: 'n'
142146
}], function (err, result) {
143147
if (err) {
144148
return console.log(err);
@@ -186,7 +190,7 @@ function writePodFile(result) {
186190
}
187191
try {
188192
fs.writeFileSync(directories.ios + '/Podfile',
189-
`pod 'Firebase', '~> 3.11.0'
193+
`pod 'Firebase', '~> 3.13.0'
190194
pod 'Firebase/Database'
191195
pod 'Firebase/Auth'
192196
@@ -202,6 +206,9 @@ pod 'Firebase/Auth'
202206
# Uncomment if you want to enable Firebase Storage
203207
` + (isSelected(result.storage) ? `` : `#`) + `pod 'Firebase/Storage'
204208
209+
# Uncomment if you want to enable AdMob
210+
` + (isSelected(result.admob) ? `` : `#`) + `pod 'Firebase/AdMob'
211+
205212
# Uncomment if you want to enable Facebook Authentication
206213
` + (isSelected(result.facebook_auth) ? `` : `#`) + `pod 'FBSDKCoreKit'
207214
` + (isSelected(result.facebook_auth) ? `` : `#`) + `pod 'FBSDKLoginKit'
@@ -242,25 +249,28 @@ repositories {
242249
243250
dependencies {
244251
// make sure you have these versions by updating your local Android SDK's (Android Support repo and Google repo)
245-
compile "com.google.firebase:firebase-core:10.0.+"
246-
compile "com.google.firebase:firebase-database:10.0.+"
247-
compile "com.google.firebase:firebase-auth:10.0.+"
252+
compile "com.google.firebase:firebase-core:10.2.+"
253+
compile "com.google.firebase:firebase-database:10.2.+"
254+
compile "com.google.firebase:firebase-auth:10.2.+"
248255
249256
// for reading google-services.json and configuration
250-
def googlePlayServicesVersion = project.hasProperty('googlePlayServicesVersion') ? project.googlePlayServicesVersion : '10.0.+'
257+
def googlePlayServicesVersion = project.hasProperty('googlePlayServicesVersion') ? project.googlePlayServicesVersion : '10.2.+'
251258
compile "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
252259
253260
// Uncomment if you want to use 'Remote Config'
254-
` + (isSelected(result.remote_config) ? `` : `//`) + ` compile "com.google.firebase:firebase-config:10.0.+"
261+
` + (isSelected(result.remote_config) ? `` : `//`) + ` compile "com.google.firebase:firebase-config:10.2.+"
255262
256263
// Uncomment if you want to use 'Crash Reporting'
257-
` + (isSelected(result.crash_reporting) ? `` : `//`) + ` compile "com.google.firebase:firebase-crash:10.0.+"
264+
` + (isSelected(result.crash_reporting) ? `` : `//`) + ` compile "com.google.firebase:firebase-crash:10.2.+"
258265
259266
// Uncomment if you want FCM (Firebase Cloud Messaging)
260-
` + (isSelected(result.messaging) ? `` : `//`) + ` compile "com.google.firebase:firebase-messaging:10.0.+"
267+
` + (isSelected(result.messaging) ? `` : `//`) + ` compile "com.google.firebase:firebase-messaging:10.2.+"
261268
262269
// Uncomment if you want Google Cloud Storage
263-
` + (isSelected(result.storage) ? `` : `//`) + ` compile 'com.google.firebase:firebase-storage:10.0.+'
270+
` + (isSelected(result.storage) ? `` : `//`) + ` compile 'com.google.firebase:firebase-storage:10.2.+'
271+
272+
// Uncomment if you want AdMob
273+
` + (isSelected(result.admob) ? `` : `//`) + ` compile 'com.google.firebase:firebase-ads:10.2.+'
264274
265275
// Uncomment if you need Facebook Authentication
266276
` + (isSelected(result.facebook_auth) ? `` : `//`) + ` compile "com.facebook.android:facebook-android-sdk:4.+"

scripts/postinstall.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2948,6 +2948,10 @@ function promptQuestions() {
29482948
name: 'google_auth',
29492949
description: 'Are you using Firebase Google Authentication (y/n)',
29502950
default: 'n'
2951+
}, {
2952+
name: 'admob',
2953+
description: 'Are you using AdMob (y/n)',
2954+
default: 'n'
29512955
}], function (err, result) {
29522956
if (err) {
29532957
return console.log(err);
@@ -2995,7 +2999,7 @@ function writePodFile(result) {
29952999
}
29963000
try {
29973001
fs.writeFileSync(directories.ios + '/Podfile',
2998-
`pod 'Firebase', '~> 3.11.0'
3002+
`pod 'Firebase', '~> 3.13.0'
29993003
pod 'Firebase/Database'
30003004
pod 'Firebase/Auth'
30013005
@@ -3011,6 +3015,9 @@ pod 'Firebase/Auth'
30113015
# Uncomment if you want to enable Firebase Storage
30123016
` + (isSelected(result.storage) ? `` : `#`) + `pod 'Firebase/Storage'
30133017
3018+
# Uncomment if you want to enable AdMob
3019+
` + (isSelected(result.admob) ? `` : `#`) + `pod 'Firebase/AdMob'
3020+
30143021
# Uncomment if you want to enable Facebook Authentication
30153022
` + (isSelected(result.facebook_auth) ? `` : `#`) + `pod 'FBSDKCoreKit'
30163023
` + (isSelected(result.facebook_auth) ? `` : `#`) + `pod 'FBSDKLoginKit'
@@ -3051,25 +3058,28 @@ repositories {
30513058
30523059
dependencies {
30533060
// make sure you have these versions by updating your local Android SDK's (Android Support repo and Google repo)
3054-
compile "com.google.firebase:firebase-core:10.0.+"
3055-
compile "com.google.firebase:firebase-database:10.0.+"
3056-
compile "com.google.firebase:firebase-auth:10.0.+"
3061+
compile "com.google.firebase:firebase-core:10.2.+"
3062+
compile "com.google.firebase:firebase-database:10.2.+"
3063+
compile "com.google.firebase:firebase-auth:10.2.+"
30573064
30583065
// for reading google-services.json and configuration
3059-
def googlePlayServicesVersion = project.hasProperty('googlePlayServicesVersion') ? project.googlePlayServicesVersion : '10.0.+'
3066+
def googlePlayServicesVersion = project.hasProperty('googlePlayServicesVersion') ? project.googlePlayServicesVersion : '10.2.+'
30603067
compile "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
30613068
30623069
// Uncomment if you want to use 'Remote Config'
3063-
` + (isSelected(result.remote_config) ? `` : `//`) + ` compile "com.google.firebase:firebase-config:10.0.+"
3070+
` + (isSelected(result.remote_config) ? `` : `//`) + ` compile "com.google.firebase:firebase-config:10.2.+"
30643071
30653072
// Uncomment if you want to use 'Crash Reporting'
3066-
` + (isSelected(result.crash_reporting) ? `` : `//`) + ` compile "com.google.firebase:firebase-crash:10.0.+"
3073+
` + (isSelected(result.crash_reporting) ? `` : `//`) + ` compile "com.google.firebase:firebase-crash:10.2.+"
30673074
30683075
// Uncomment if you want FCM (Firebase Cloud Messaging)
3069-
` + (isSelected(result.messaging) ? `` : `//`) + ` compile "com.google.firebase:firebase-messaging:10.0.+"
3076+
` + (isSelected(result.messaging) ? `` : `//`) + ` compile "com.google.firebase:firebase-messaging:10.2.+"
30703077
30713078
// Uncomment if you want Google Cloud Storage
3072-
` + (isSelected(result.storage) ? `` : `//`) + ` compile 'com.google.firebase:firebase-storage:10.0.+'
3079+
` + (isSelected(result.storage) ? `` : `//`) + ` compile 'com.google.firebase:firebase-storage:10.2.+'
3080+
3081+
// Uncomment if you want AdMob
3082+
` + (isSelected(result.admob) ? `` : `//`) + ` compile 'com.google.firebase:firebase-ads:10.2.+'
30733083
30743084
// Uncomment if you need Facebook Authentication
30753085
` + (isSelected(result.facebook_auth) ? `` : `//`) + ` compile "com.facebook.android:facebook-android-sdk:4.+"

0 commit comments

Comments
 (0)