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

Commit 1484dd8

Browse files
Error using admob #601
1 parent e6f4b4d commit 1484dd8

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@
1010

1111
- [#170](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/170) Need a way to unregister push notification from Firebase
1212

13+
### Fixes
14+
- [#601](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/601) Error using admob
1315

14-
## 5.1.2 (2018, January 8)
1516

16-
### Fixes
17-
- [#594](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/594) Android - Background notification causing app to crash after upgrade to 5.1.1
17+
## 5.1.2 (2018, January 8)
1818

1919
### New
2020
- [#595](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/595) Creating Observables from Firestore Documents/Collections
2121

22+
### Fixes
23+
- [#594](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/594) Android - Background notification causing app to crash after upgrade to 5.1.1
24+
2225

2326
## 5.1.1 (2017, December 30)
2427

src/firebase.android.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,8 @@ firebase.admob.showInterstitial = arg => {
634634
return new Promise((resolve, reject) => {
635635
try {
636636
const settings = firebase.merge(arg, firebase.admob.defaults);
637-
firebase.admob.interstitialView = new com.google.android.gms.ads.InterstitialAd(appModule.android.foregroundActivity);
637+
const activity = appModule.android.foregroundActivity || appModule.android.startActivity;
638+
firebase.admob.interstitialView = new com.google.android.gms.ads.InterstitialAd(activity);
638639
firebase.admob.interstitialView.setAdUnitId(settings.androidInterstitialId);
639640

640641
// Interstitial ads must be loaded before they can be shown, so adding a listener
@@ -703,7 +704,8 @@ firebase.admob._buildAdRequest = settings => {
703704
if (settings.testing) {
704705
builder.addTestDevice(com.google.android.gms.ads.AdRequest.DEVICE_ID_EMULATOR);
705706
// This will request test ads on the emulator and device by passing this hashed device ID.
706-
const ANDROID_ID = android.provider.Settings.Secure.getString(appModule.android.foregroundActivity.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
707+
const activity = appModule.android.foregroundActivity || appModule.android.startActivity;
708+
const ANDROID_ID = android.provider.Settings.Secure.getString(activity.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
707709
let deviceId = firebase.admob._md5(ANDROID_ID);
708710
if (deviceId !== null) {
709711
deviceId = deviceId.toUpperCase();

0 commit comments

Comments
 (0)