react-native-google-mobile-ads 8.1.2 → 8.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import { AdEventType, InterstitialAd } from '../src';
2
+ import { NativeModules } from 'react-native';
2
3
 
3
4
  describe('Google Mobile Ads Interstitial', function () {
4
5
  describe('createForAdRequest', function () {
@@ -24,6 +25,65 @@ describe('Google Mobile Ads Interstitial', function () {
24
25
  expect(i.loaded).toEqual(false);
25
26
  });
26
27
 
28
+ describe('load()', () => {
29
+ afterEach(() => {
30
+ jest.clearAllMocks();
31
+ });
32
+
33
+ it('does call native load method', () => {
34
+ const ad = InterstitialAd.createForAdRequest('abc');
35
+
36
+ ad.load();
37
+ expect(NativeModules.RNGoogleMobileAdsModule.interstitialLoad).toBeCalledTimes(1);
38
+ });
39
+
40
+ it('does nothing if ad currently loading', () => {
41
+ const ad = InterstitialAd.createForAdRequest('abc');
42
+
43
+ ad.load();
44
+ expect(NativeModules.RNGoogleMobileAdsModule.interstitialLoad).toBeCalledTimes(1);
45
+
46
+ ad.load();
47
+ expect(NativeModules.RNGoogleMobileAdsModule.interstitialLoad).toBeCalledTimes(1);
48
+ });
49
+
50
+ it('does nothing if ad is already loaded', () => {
51
+ const ad = InterstitialAd.createForAdRequest('abc');
52
+
53
+ // @ts-ignore
54
+ ad._handleAdEvent({ body: { type: AdEventType.LOADED } });
55
+
56
+ ad.load();
57
+ expect(NativeModules.RNGoogleMobileAdsModule.interstitialLoad).not.toBeCalled();
58
+ });
59
+
60
+ it('can be called again after ad was closed', () => {
61
+ const ad = InterstitialAd.createForAdRequest('abc');
62
+
63
+ ad.load();
64
+ expect(NativeModules.RNGoogleMobileAdsModule.interstitialLoad).toBeCalledTimes(1);
65
+
66
+ // @ts-ignore
67
+ ad._handleAdEvent({ body: { type: AdEventType.CLOSED } });
68
+
69
+ ad.load();
70
+ expect(NativeModules.RNGoogleMobileAdsModule.interstitialLoad).toBeCalledTimes(2);
71
+ });
72
+
73
+ it('can be called again after ad failed to load', () => {
74
+ const ad = InterstitialAd.createForAdRequest('abc');
75
+
76
+ ad.load();
77
+ expect(NativeModules.RNGoogleMobileAdsModule.interstitialLoad).toBeCalledTimes(1);
78
+
79
+ // @ts-ignore
80
+ ad._handleAdEvent({ body: { type: AdEventType.ERROR } });
81
+
82
+ ad.load();
83
+ expect(NativeModules.RNGoogleMobileAdsModule.interstitialLoad).toBeCalledTimes(2);
84
+ });
85
+ });
86
+
27
87
  describe('show', function () {
28
88
  it('throws if showing before loaded', function () {
29
89
  const i = InterstitialAd.createForAdRequest('abc');
package/docs/index.mdx CHANGED
@@ -9,7 +9,27 @@ yarn add react-native-google-mobile-ads
9
9
 
10
10
  ## Optionally configure iOS static frameworks
11
11
 
12
- On iOS if you need to use static frameworks (that is, `use_frameworks!` in your `Podfile`) you must add the variable `$RNGoogleMobileAdsAsStaticFramework = true` to the targets in your `Podfile`. You may need this if you use this module in combination with react-native-firebase v15 and higher since it requires `use_frameworks!`.
12
+ On iOS if you need to use static frameworks (that is, `use_frameworks! :linkage => :static` in your `Podfile`) you must add the variable `$RNGoogleMobileAdsAsStaticFramework = true` to the targets in your `Podfile`. You may need this if you use this module in combination with react-native-firebase v15 and higher since it requires `use_frameworks!`.
13
+
14
+ Expo users may enable static frameworks by using the `expo-build-properties` plugin.
15
+ To do so [follow the official `expo-build-properties` installation instructions](https://docs.expo.dev/versions/latest/sdk/build-properties/) and merge the following code into your `app.json` file:
16
+
17
+ ```json
18
+ {
19
+ "expo": {
20
+ "plugins": [
21
+ [
22
+ "expo-build-properties",
23
+ {
24
+ "ios": {
25
+ "useFrameworks": "static"
26
+ }
27
+ }
28
+ ]
29
+ ]
30
+ }
31
+ }
32
+ ```
13
33
 
14
34
  ## What does it do
15
35
 
@@ -62,6 +82,22 @@ Within the root of your React Native project, open the `app.json` file and add t
62
82
  }
63
83
  ```
64
84
 
85
+ If you're an expo user, make sure the `react-native-google-mobile-ads` block is outside of the `expo` block!
86
+ It should look like this:
87
+
88
+ ```json
89
+ // <project-root>/app.json
90
+ {
91
+ "expo": {
92
+ // ...
93
+ },
94
+ "react-native-google-mobile-ads": {
95
+ "android_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",
96
+ "ios_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx"
97
+ }
98
+ }
99
+ ```
100
+
65
101
  For the changes to take effect, rebuild your project:
66
102
 
67
103
  ```bash
@@ -71,6 +107,12 @@ npx react-native run-ios
71
107
 
72
108
  # For Android
73
109
  npx react-native run-android
110
+
111
+ # For expo users not using EAS
112
+ npx expo prebuild
113
+
114
+ # For expo users using EAS
115
+ npx eas-cli build --profile development
74
116
  ```
75
117
 
76
118
  ### Configure outbound requests
package/jest.setup.ts CHANGED
@@ -12,12 +12,15 @@ jest.doMock('react-native', () => {
12
12
  RNAppModule: {
13
13
  addListener: jest.fn(),
14
14
  removeListeners: jest.fn(),
15
+ eventsAddListener: jest.fn(),
16
+ eventsNotifyReady: jest.fn(),
15
17
  },
16
18
  RNGoogleMobileAdsModule: {
17
19
  addListener: jest.fn(),
18
20
  removeListeners: jest.fn(),
19
21
  eventsAddListener: jest.fn(),
20
22
  eventsNotifyReady: jest.fn(),
23
+ interstitialLoad: jest.fn(),
21
24
  },
22
25
  RNGoogleMobileAdsInterstitialModule: {},
23
26
  RNGoogleMobileAdsRewardedModule: {},
@@ -59,6 +59,10 @@ class MobileAd {
59
59
  this._loaded = false;
60
60
  this._isLoadCalled = false;
61
61
  }
62
+ if (type === _AdEventType.AdEventType.ERROR) {
63
+ this._loaded = false;
64
+ this._isLoadCalled = false;
65
+ }
62
66
  let payload = data;
63
67
  if (error) {
64
68
  payload = _NativeError.NativeError.fromEvent(error, 'googleMobileAds');
@@ -1 +1 @@
1
- {"version":3,"names":["MobileAd","constructor","type","googleMobileAds","requestId","adUnitId","requestOptions","_type","_googleMobileAds","_requestId","_adUnitId","_requestOptions","_loaded","_isLoadCalled","_adEventsListeners","Map","_adEventListenersMap","Object","values","AdEventType","RewardedAdEventType","GAMAdEventType","_","LOADED","forEach","set","_adEventListenerId","_adEventsListenerId","_nativeListener","emitter","addListener","_handleAdEvent","bind","event","error","data","body","CLOSED","payload","NativeError","fromEvent","listener","_getAdEventListeners","_addAdEventsListener","isFunction","Error","_className","id","delete","_addAdEventListener","isOneOf","get","name","_camelCaseType","load","native","show","showOptions","options","validateAdShowOptions","e","message","removeAllListeners","clear","map","loaded"],"sources":["MobileAd.ts"],"sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport { EmitterSubscription } from 'react-native';\nimport { isFunction, isOneOf } from '../common';\nimport { NativeError } from '../internal/NativeError';\nimport { AdEventType } from '../AdEventType';\nimport { RewardedAdEventType } from '../RewardedAdEventType';\nimport { AdEventListener, AdEventPayload } from '../types/AdEventListener';\nimport { AdEventsListener } from '../types/AdEventsListener';\nimport { AdShowOptions } from '../types/AdShowOptions';\nimport { RequestOptions } from '../types/RequestOptions';\nimport { MobileAdInterface } from '../types/MobileAd.interface';\nimport { MobileAdsModuleInterface } from '../types/MobileAdsModule.interface';\nimport { RewardedAdReward } from '../types/RewardedAdReward';\nimport { GAMAdEventType } from '../GAMAdEventType';\nimport { AppEvent } from '../types/AppEvent';\nimport { validateAdShowOptions } from '../validateAdShowOptions';\n\ntype EventType = AdEventType | RewardedAdEventType | GAMAdEventType;\n\nexport abstract class MobileAd implements MobileAdInterface {\n protected _type: 'app_open' | 'interstitial' | 'rewarded' | 'rewarded_interstitial';\n protected _googleMobileAds: MobileAdsModuleInterface;\n protected _requestId: number;\n protected _adUnitId: string;\n protected _requestOptions: RequestOptions;\n protected _loaded: boolean;\n protected _isLoadCalled: boolean;\n protected _adEventsListeners: Map<number, AdEventsListener<EventType>>;\n protected _adEventListenersMap: Map<EventType, Map<number, AdEventListener<EventType>>>;\n protected _adEventsListenerId: number;\n protected _adEventListenerId: number;\n protected _nativeListener: EmitterSubscription;\n\n protected constructor(\n type: 'app_open' | 'interstitial' | 'rewarded' | 'rewarded_interstitial',\n googleMobileAds: MobileAdsModuleInterface,\n requestId: number,\n adUnitId: string,\n requestOptions: RequestOptions,\n ) {\n this._type = type;\n this._googleMobileAds = googleMobileAds;\n this._requestId = requestId;\n this._adUnitId = adUnitId;\n this._requestOptions = requestOptions;\n\n this._loaded = false;\n this._isLoadCalled = false;\n this._adEventsListeners = new Map();\n this._adEventListenersMap = new Map();\n Object.values({\n ...AdEventType,\n ...RewardedAdEventType,\n ...GAMAdEventType,\n _: AdEventType.LOADED, // since AdEventType.LOADED is overwritten by RewardedAdEventType.LOADED\n }).forEach(type => {\n this._adEventListenersMap.set(type as EventType, new Map());\n });\n this._adEventListenerId = 0;\n this._adEventsListenerId = 0;\n\n this._nativeListener = googleMobileAds.emitter.addListener(\n `google_mobile_ads_${type}_event:${adUnitId}:${requestId}`,\n this._handleAdEvent.bind(this),\n );\n }\n\n protected _handleAdEvent(event: {\n body: {\n type: EventType;\n error?: { code: string; message: string };\n data?: RewardedAdReward | AppEvent;\n };\n }) {\n const { type, error, data } = event.body;\n\n if (type === AdEventType.LOADED || type === RewardedAdEventType.LOADED) {\n this._loaded = true;\n }\n\n if (type === AdEventType.CLOSED) {\n this._loaded = false;\n this._isLoadCalled = false;\n }\n\n let payload: AdEventPayload<EventType> = data;\n if (error) {\n payload = NativeError.fromEvent(error, 'googleMobileAds');\n }\n this._adEventsListeners.forEach(listener => {\n listener({\n type,\n payload,\n });\n });\n this._getAdEventListeners(type).forEach(listener => {\n listener(payload);\n });\n }\n\n protected _addAdEventsListener<T extends EventType>(listener: AdEventsListener<T>) {\n if (!isFunction(listener)) {\n throw new Error(`${this._className}.addAdEventsListener(*) 'listener' expected a function.`);\n }\n\n const id = this._adEventsListenerId++;\n this._adEventsListeners.set(id, listener as AdEventsListener<EventType>);\n return () => {\n this._adEventsListeners.delete(id);\n };\n }\n\n protected _addAdEventListener<T extends EventType>(type: T, listener: AdEventListener<T>) {\n if (\n !(\n isOneOf(type, Object.values(AdEventType)) ||\n (isOneOf(type, Object.values(RewardedAdEventType)) &&\n (this._type === 'rewarded' || this._type === 'rewarded_interstitial'))\n )\n ) {\n throw new Error(\n `${this._className}.addAdEventListener(*) 'type' expected a valid event type value.`,\n );\n }\n if (!isFunction(listener)) {\n throw new Error(\n `${this._className}.addAdEventListener(_, *) 'listener' expected a function.`,\n );\n }\n\n const id = this._adEventListenerId++;\n this._getAdEventListeners(type).set(id, listener);\n return () => {\n this._getAdEventListeners(type).delete(id);\n };\n }\n\n protected _getAdEventListeners<T extends EventType>(type: T) {\n return this._adEventListenersMap.get(type) as Map<number, AdEventListener<T>>;\n }\n\n protected get _className() {\n return this.constructor.name;\n }\n\n protected get _camelCaseType() {\n let type: 'appOpen' | 'interstitial' | 'rewarded' | 'rewardedInterstitial';\n if (this._type === 'app_open') {\n type = 'appOpen';\n } else if (this._type === 'rewarded_interstitial') {\n type = 'rewardedInterstitial';\n } else {\n type = this._type;\n }\n return type;\n }\n\n public load() {\n // Prevent multiple load calls\n if (this._loaded || this._isLoadCalled) {\n return;\n }\n\n this._isLoadCalled = true;\n const load = this._googleMobileAds.native[`${this._camelCaseType}Load`];\n load(this._requestId, this._adUnitId, this._requestOptions);\n }\n\n public show(showOptions?: AdShowOptions) {\n if (!this._loaded) {\n throw new Error(\n `${this._className}.show() The requested ${this._className} has not loaded and could not be shown.`,\n );\n }\n\n let options;\n try {\n options = validateAdShowOptions(showOptions);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`${this._className}.show(*) ${e.message}.`);\n } else {\n throw e;\n }\n }\n\n const show = this._googleMobileAds.native[`${this._camelCaseType}Show`];\n return show(this._requestId, this._adUnitId, options);\n }\n\n public abstract addAdEventsListener<T extends never>(listener: AdEventsListener<T>): () => void;\n\n public abstract addAdEventListener<T extends never>(type: T, listener: AdEventListener<T>): void;\n\n public removeAllListeners() {\n this._adEventsListeners.clear();\n this._adEventListenersMap.forEach((_, type, map) => {\n map.set(type, new Map());\n });\n }\n\n public get adUnitId() {\n return this._adUnitId;\n }\n\n public get loaded() {\n return this._loaded;\n }\n}\n"],"mappings":";;;;;;AAkBA;AACA;AACA;AACA;AAQA;AAEA;AAAiE;AAI1D,MAAeA,QAAQ,CAA8B;EAchDC,WAAW,CACnBC,IAAwE,EACxEC,eAAyC,EACzCC,SAAiB,EACjBC,QAAgB,EAChBC,cAA8B,EAC9B;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IACA,IAAI,CAACC,KAAK,GAAGL,IAAI;IACjB,IAAI,CAACM,gBAAgB,GAAGL,eAAe;IACvC,IAAI,CAACM,UAAU,GAAGL,SAAS;IAC3B,IAAI,CAACM,SAAS,GAAGL,QAAQ;IACzB,IAAI,CAACM,eAAe,GAAGL,cAAc;IAErC,IAAI,CAACM,OAAO,GAAG,KAAK;IACpB,IAAI,CAACC,aAAa,GAAG,KAAK;IAC1B,IAAI,CAACC,kBAAkB,GAAG,IAAIC,GAAG,EAAE;IACnC,IAAI,CAACC,oBAAoB,GAAG,IAAID,GAAG,EAAE;IACrCE,MAAM,CAACC,MAAM,CAAC;MACZ,GAAGC,wBAAW;MACd,GAAGC,wCAAmB;MACtB,GAAGC,8BAAc;MACjBC,CAAC,EAAEH,wBAAW,CAACI,MAAM,CAAE;IACzB,CAAC,CAAC,CAACC,OAAO,CAACtB,IAAI,IAAI;MACjB,IAAI,CAACc,oBAAoB,CAACS,GAAG,CAACvB,IAAI,EAAe,IAAIa,GAAG,EAAE,CAAC;IAC7D,CAA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AAI,CAAC/C,UAAU,EAAE,IAAI,CAACC,SAAS,EAAEgD,OAAO,CAAC;EACvD;EAMOI,kBAAkB,GAAG;IAC1B,IAAI,CAAChD,kBAAkB,CAACiD,KAAK,EAAE;IAC/B,IAAI,CAAC/C,oBAAoB,CAACQ,OAAO,CAAC,CAACF,CAAC,EAAEpB,IAAI,EAAE8D,GAAG,KAAK;MAClDA,GAAG,CAACvC,GAAG,CAACvB,IAAI,EAAE,IAAIa,GAAG,EAAE,CAAC;IAC1B,CAAC,CAAC;EACJ;EAEA,IAAWV,QAAQ,GAAG;IACpB,OAAO,IAAI,CAACK,SAAS;EACvB;EAEA,IAAWuD,MAAM,GAAG;IAClB,OAAO,IAAI,CAACrD,OAAO;EACrB;AACF;AAAC"}
1
+ {"version":3,"names":["MobileAd","constructor","type","googleMobileAds","requestId","adUnitId","requestOptions","_type","_googleMobileAds","_requestId","_adUnitId","_requestOptions","_loaded","_isLoadCalled","_adEventsListeners","Map","_adEventListenersMap","Object","values","AdEventType","RewardedAdEventType","GAMAdEventType","_","LOADED","forEach","set","_adEventListenerId","_adEventsListenerId","_nativeListener","emitter","addListener","_handleAdEvent","bind","event","error","data","body","CLOSED","ERROR","payload","NativeError","fromEvent","listener","_getAdEventListeners","_addAdEventsListener","isFunction","Error","_className","id","delete","_addAdEventListener","isOneOf","get","name","_camelCaseType","load","native","show","showOptions","options","validateAdShowOptions","e","message","removeAllListeners","clear","map","loaded"],"sources":["MobileAd.ts"],"sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport { EmitterSubscription } from 'react-native';\nimport { isFunction, isOneOf } from '../common';\nimport { NativeError } from '../internal/NativeError';\nimport { AdEventType } from '../AdEventType';\nimport { RewardedAdEventType } from '../RewardedAdEventType';\nimport { AdEventListener, AdEventPayload } from '../types/AdEventListener';\nimport { AdEventsListener } from '../types/AdEventsListener';\nimport { AdShowOptions } from '../types/AdShowOptions';\nimport { RequestOptions } from '../types/RequestOptions';\nimport { MobileAdInterface } from '../types/MobileAd.interface';\nimport { MobileAdsModuleInterface } from '../types/MobileAdsModule.interface';\nimport { RewardedAdReward } from '../types/RewardedAdReward';\nimport { GAMAdEventType } from '../GAMAdEventType';\nimport { AppEvent } from '../types/AppEvent';\nimport { validateAdShowOptions } from '../validateAdShowOptions';\n\ntype EventType = AdEventType | RewardedAdEventType | GAMAdEventType;\n\nexport abstract class MobileAd implements MobileAdInterface {\n protected _type: 'app_open' | 'interstitial' | 'rewarded' | 'rewarded_interstitial';\n protected _googleMobileAds: MobileAdsModuleInterface;\n protected _requestId: number;\n protected _adUnitId: string;\n protected _requestOptions: RequestOptions;\n protected _loaded: boolean;\n protected _isLoadCalled: boolean;\n protected _adEventsListeners: Map<number, AdEventsListener<EventType>>;\n protected _adEventListenersMap: Map<EventType, Map<number, AdEventListener<EventType>>>;\n protected _adEventsListenerId: number;\n protected _adEventListenerId: number;\n protected _nativeListener: EmitterSubscription;\n\n protected constructor(\n type: 'app_open' | 'interstitial' | 'rewarded' | 'rewarded_interstitial',\n googleMobileAds: MobileAdsModuleInterface,\n requestId: number,\n adUnitId: string,\n requestOptions: RequestOptions,\n ) {\n this._type = type;\n this._googleMobileAds = googleMobileAds;\n this._requestId = requestId;\n this._adUnitId = adUnitId;\n this._requestOptions = requestOptions;\n\n this._loaded = false;\n this._isLoadCalled = false;\n this._adEventsListeners = new Map();\n this._adEventListenersMap = new Map();\n Object.values({\n ...AdEventType,\n ...RewardedAdEventType,\n ...GAMAdEventType,\n _: AdEventType.LOADED, // since AdEventType.LOADED is overwritten by RewardedAdEventType.LOADED\n }).forEach(type => {\n this._adEventListenersMap.set(type as EventType, new Map());\n });\n this._adEventListenerId = 0;\n this._adEventsListenerId = 0;\n\n this._nativeListener = googleMobileAds.emitter.addListener(\n `google_mobile_ads_${type}_event:${adUnitId}:${requestId}`,\n this._handleAdEvent.bind(this),\n );\n }\n\n protected _handleAdEvent(event: {\n body: {\n type: EventType;\n error?: { code: string; message: string };\n data?: RewardedAdReward | AppEvent;\n };\n }) {\n const { type, error, data } = event.body;\n\n if (type === AdEventType.LOADED || type === RewardedAdEventType.LOADED) {\n this._loaded = true;\n }\n\n if (type === AdEventType.CLOSED) {\n this._loaded = false;\n this._isLoadCalled = false;\n }\n\n if (type === AdEventType.ERROR) {\n this._loaded = false;\n this._isLoadCalled = false;\n }\n\n let payload: AdEventPayload<EventType> = data;\n if (error) {\n payload = NativeError.fromEvent(error, 'googleMobileAds');\n }\n this._adEventsListeners.forEach(listener => {\n listener({\n type,\n payload,\n });\n });\n this._getAdEventListeners(type).forEach(listener => {\n listener(payload);\n });\n }\n\n protected _addAdEventsListener<T extends EventType>(listener: AdEventsListener<T>) {\n if (!isFunction(listener)) {\n throw new Error(`${this._className}.addAdEventsListener(*) 'listener' expected a function.`);\n }\n\n const id = this._adEventsListenerId++;\n this._adEventsListeners.set(id, listener as AdEventsListener<EventType>);\n return () => {\n this._adEventsListeners.delete(id);\n };\n }\n\n protected _addAdEventListener<T extends EventType>(type: T, listener: AdEventListener<T>) {\n if (\n !(\n isOneOf(type, Object.values(AdEventType)) ||\n (isOneOf(type, Object.values(RewardedAdEventType)) &&\n (this._type === 'rewarded' || this._type === 'rewarded_interstitial'))\n )\n ) {\n throw new Error(\n `${this._className}.addAdEventListener(*) 'type' expected a valid event type value.`,\n );\n }\n if (!isFunction(listener)) {\n throw new Error(\n `${this._className}.addAdEventListener(_, *) 'listener' expected a function.`,\n );\n }\n\n const id = this._adEventListenerId++;\n this._getAdEventListeners(type).set(id, listener);\n return () => {\n this._getAdEventListeners(type).delete(id);\n };\n }\n\n protected _getAdEventListeners<T extends EventType>(type: T) {\n return this._adEventListenersMap.get(type) as Map<number, AdEventListener<T>>;\n }\n\n protected get _className() {\n return this.constructor.name;\n }\n\n protected get _camelCaseType() {\n let type: 'appOpen' | 'interstitial' | 'rewarded' | 'rewardedInterstitial';\n if (this._type === 'app_open') {\n type = 'appOpen';\n } else if (this._type === 'rewarded_interstitial') {\n type = 'rewardedInterstitial';\n } else {\n type = this._type;\n }\n return type;\n }\n\n public load() {\n // Prevent multiple load calls\n if (this._loaded || this._isLoadCalled) {\n return;\n }\n\n this._isLoadCalled = true;\n const load = this._googleMobileAds.native[`${this._camelCaseType}Load`];\n load(this._requestId, this._adUnitId, this._requestOptions);\n }\n\n public show(showOptions?: AdShowOptions) {\n if (!this._loaded) {\n throw new Error(\n `${this._className}.show() The requested ${this._className} has not loaded and could not be shown.`,\n );\n }\n\n let options;\n try {\n options = validateAdShowOptions(showOptions);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`${this._className}.show(*) ${e.message}.`);\n } else {\n throw e;\n }\n }\n\n const show = this._googleMobileAds.native[`${this._camelCaseType}Show`];\n return show(this._requestId, this._adUnitId, options);\n }\n\n public abstract addAdEventsListener<T extends never>(listener: AdEventsListener<T>): () => void;\n\n public abstract addAdEventListener<T extends never>(type: T, listener: AdEventListener<T>): void;\n\n public removeAllListeners() {\n this._adEventsListeners.clear();\n this._adEventListenersMap.forEach((_, type, map) => {\n map.set(type, new Map());\n });\n }\n\n public get adUnitId() {\n return this._adUnitId;\n }\n\n public get loaded() {\n return this._loaded;\n }\n}\n"],"mappings":";;;;;;AAkBA;AACA;AACA;AACA;AAQA;AAEA;AAAiE;AAI1D,MAAeA,QAAQ,CAA8B;EAchDC,WAAW,CACnBC,IAAwE,EACxEC,eAAyC,EACzCC,SAAiB,EACjBC,QAAgB,EAChBC,cAA8B,EAC9B;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IA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OAAO;EACrB;AACF;AAAC"}
@@ -3,10 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getAppModule = getAppModule;
7
6
  exports.getNativeModule = getNativeModule;
8
7
  var _reactNative = require("react-native");
9
- var _constants = require("../constants");
10
8
  var _NativeError = require("../NativeError");
11
9
  var _GoogleMobileAdsNativeEventEmitter = require("../GoogleMobileAdsNativeEventEmitter");
12
10
  var _SharedEventEmitter = require("../SharedEventEmitter");
@@ -179,22 +177,4 @@ function getNativeModule(module) {
179
177
  }
180
178
  return initialiseNativeModule(module);
181
179
  }
182
-
183
- /**
184
- * Custom wrapped app module as it does not have it's own FirebaseModule based class.
185
- *
186
- * @returns {*}
187
- */
188
- function getAppModule() {
189
- if (NATIVE_MODULE_REGISTRY[_constants.APP_NATIVE_MODULE]) {
190
- return NATIVE_MODULE_REGISTRY[_constants.APP_NATIVE_MODULE];
191
- }
192
- const namespace = 'app';
193
- const nativeModule = _reactNative.NativeModules[_constants.APP_NATIVE_MODULE];
194
- if (!nativeModule) {
195
- throw new Error(getMissingModuleHelpText(namespace));
196
- }
197
- NATIVE_MODULE_REGISTRY[_constants.APP_NATIVE_MODULE] = nativeModuleWrapped(namespace, nativeModule, []);
198
- return NATIVE_MODULE_REGISTRY[_constants.APP_NATIVE_MODULE];
199
- }
200
180
  //# sourceMappingURL=nativeModule.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NATIVE_MODULE_REGISTRY","NATIVE_MODULE_EVENT_SUBSCRIPTIONS","nativeModuleKey","module","_customUrlOrRegion","app","name","_config","namespace","nativeModuleMethodWrapped","method","argToPrepend","args","possiblePromise","then","jsStack","Error","stack","catch","nativeError","Promise","reject","NativeError","nativeModuleWrapped","NativeModule","native","properties","Object","keys","i","len","length","property","isFunction","initialiseNativeModule","config","key","nativeEvents","nativeModuleName","multiModuleRoot","multiModule","Array","isArray","nativeModuleNames","nativeModule","NativeModules","getMissingModuleHelpText","assign","subscribeToNativeModuleEvent","freeze","eventName","GoogleMobileAdsNativeEventEmitter","addListener","event","appName","SharedEventEmitter","emit","snippet","charAt","toUpperCase","slice","Platform","OS","rnPackage","newInstance","getNativeModule","getAppModule","APP_NATIVE_MODULE"],"sources":["nativeModule.ts"],"sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport { NativeModules, Platform } from 'react-native';\nimport { APP_NATIVE_MODULE } from '../constants';\nimport { NativeError } from '../NativeError';\nimport { GoogleMobileAdsNativeEventEmitter } from '../GoogleMobileAdsNativeEventEmitter';\nimport { SharedEventEmitter } from '../SharedEventEmitter';\nimport { isFunction } from '../../common';\nimport { ModuleInterface } from '../../types/Module.interface';\n\nconst NATIVE_MODULE_REGISTRY: Record<string, unknown> = {};\nconst NATIVE_MODULE_EVENT_SUBSCRIPTIONS: Record<string, unknown> = {};\n\nfunction nativeModuleKey(module: ModuleInterface) {\n return `${module._customUrlOrRegion || ''}:${module.app.name}:${module._config.namespace}`;\n}\n\n/**\n * Wraps a native module method to provide\n * auto prepended args and custom Error classes.\n *\n * @param namespace\n * @param method\n * @param argToPrepend\n * @returns {Function}\n */\nfunction nativeModuleMethodWrapped(\n namespace: string,\n method: (...args: unknown[]) => Promise<unknown> | void,\n argToPrepend: [],\n) {\n return (...args: []) => {\n const possiblePromise = method(...[...argToPrepend, ...args]);\n\n // @ts-ignore -- return type is Promise, so tsc infers we *know* it is a promise and .then always exists, but\n // but the typing is actually speculative, we do need to test it\n if (possiblePromise && possiblePromise.then) {\n const jsStack = new Error().stack || '';\n return possiblePromise.catch(nativeError =>\n Promise.reject(new NativeError(nativeError, jsStack, namespace)),\n );\n }\n\n return possiblePromise;\n };\n}\n\n/**\n * Prepends all arguments in prependArgs to all native method calls\n *\n * @param namespace\n * @param NativeModule\n * @param argToPrepend\n */\nfunction nativeModuleWrapped(\n namespace: string,\n NativeModule: Record<string, (...args: unknown[]) => Promise<unknown> | void>,\n argToPrepend: [],\n) {\n const native: Record<string, unknown> = {};\n if (!NativeModule) {\n return NativeModule;\n }\n\n const properties = Object.keys(NativeModule);\n\n for (let i = 0, len = properties.length; i < len; i++) {\n const property = properties[i];\n if (isFunction(NativeModule[property])) {\n native[property] = nativeModuleMethodWrapped(namespace, NativeModule[property], argToPrepend);\n } else {\n native[property] = NativeModule[property];\n }\n }\n\n return native;\n}\n\n/**\n * Initialises and wraps all the native module methods.\n *\n * @param module\n * @returns {*}\n */\nfunction initialiseNativeModule(module: ModuleInterface) {\n const config = module._config;\n const key = nativeModuleKey(module);\n const { namespace, nativeEvents, nativeModuleName } = config;\n const multiModuleRoot: Record<string, unknown> = {};\n const multiModule = Array.isArray(nativeModuleName);\n const nativeModuleNames = multiModule ? nativeModuleName : [nativeModuleName];\n\n for (let i = 0; i < nativeModuleNames.length; i++) {\n const nativeModule = NativeModules[nativeModuleNames[i]];\n\n // only error if there's a single native module\n // as multi modules can mean some are optional\n if (!multiModule && !nativeModule) {\n throw new Error(getMissingModuleHelpText(namespace));\n }\n\n if (multiModule) {\n multiModuleRoot[nativeModuleNames[i]] = !!nativeModule;\n }\n\n Object.assign(multiModuleRoot, nativeModuleWrapped(namespace, nativeModule, []));\n }\n\n if (nativeEvents && nativeEvents.length) {\n for (let i = 0, len = nativeEvents.length; i < len; i++) {\n subscribeToNativeModuleEvent(nativeEvents[i]);\n }\n }\n\n Object.freeze(multiModuleRoot);\n\n NATIVE_MODULE_REGISTRY[key] = multiModuleRoot;\n\n return NATIVE_MODULE_REGISTRY[key];\n}\n\n/**\n * Subscribe to a native event for js side distribution by appName\n * React Native events are hard set at compile - cant do dynamic event names\n * so we use a single event send it to js and js then internally can prefix it\n * and distribute dynamically.\n *\n * @param eventName\n * @private\n */\nfunction subscribeToNativeModuleEvent(eventName: string) {\n if (!NATIVE_MODULE_EVENT_SUBSCRIPTIONS[eventName]) {\n GoogleMobileAdsNativeEventEmitter.addListener(eventName, event => {\n if (event.appName) {\n // native event has an appName property - auto prefix and internally emit\n SharedEventEmitter.emit(`${event.appName}-${eventName}`, event);\n } else {\n // standard event - no need to prefix\n SharedEventEmitter.emit(eventName, event);\n }\n });\n\n NATIVE_MODULE_EVENT_SUBSCRIPTIONS[eventName] = true;\n }\n}\n\n/**\n * Help text for integrating the native counter parts for each module.\n *\n * @param namespace\n * @returns {string}\n */\nfunction getMissingModuleHelpText(namespace: string) {\n const snippet = `${namespace}()`;\n const nativeModule = namespace.charAt(0).toUpperCase() + namespace.slice(1);\n\n if (Platform.OS === 'ios') {\n return (\n `You attempted to use a module that's not installed natively on your iOS project by calling ${snippet}.` +\n '\\r\\n\\r\\nEnsure you have either linked the module or added it to your projects Podfile.' +\n '\\r\\n\\r\\nSee http://invertase.link/ios for full setup instructions.'\n );\n }\n\n const rnPackage = `'io.invertase.${namespace}.ReactNative${nativeModule}Package'`;\n const newInstance = `'new ReactNative${nativeModule}Package()'`;\n\n return (\n `You attempted to use a module that's not installed on your Android project by calling ${snippet}.` +\n `\\r\\n\\r\\nEnsure you have:\\r\\n\\r\\n1) imported the ${rnPackage} module in your 'MainApplication.java' file.\\r\\n\\r\\n2) Added the ` +\n `${newInstance} line inside of the RN 'getPackages()' method list.` +\n '\\r\\n\\r\\nSee http://invertase.link/android for full setup instructions.'\n );\n}\n\n/**\n * Gets a wrapped native module instance for the provided module.\n * Will attempt to create a new instance if non previously created.\n *\n * @param module\n * @returns {*}\n */\nexport function getNativeModule(module: ModuleInterface) {\n const key = nativeModuleKey(module);\n\n if (NATIVE_MODULE_REGISTRY[key]) {\n return NATIVE_MODULE_REGISTRY[key];\n }\n\n return initialiseNativeModule(module);\n}\n\n/**\n * Custom wrapped app module as it does not have it's own FirebaseModule based class.\n *\n * @returns {*}\n */\nexport function getAppModule() {\n if (NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE]) {\n return NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE];\n }\n\n const namespace = 'app';\n const nativeModule = NativeModules[APP_NATIVE_MODULE];\n\n if (!nativeModule) {\n throw new Error(getMissingModuleHelpText(namespace));\n }\n\n NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE] = nativeModuleWrapped(namespace, nativeModule, []);\n\n return NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE];\n}\n"],"mappings":";;;;;;;AAiBA;AACA;AACA;AACA;AACA;AACA;AAtBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,MAAMA,sBAA+C,GAAG,CAAC,CAAC;AAC1D,MAAMC,iCAA0D,GAAG,CAAC,CAAC;AAErE,SAASC,eAAe,CAACC,MAAuB,EAAE;EAChD,OAAQ,GAAEA,MAAM,CAACC,kBAAkB,IAAI,EAAG,IAAGD,MAAM,CAACE,GAAG,CAACC,IAAK,IAAGH,MAAM,CAACI,OAAO,CAACC,SAAU,EAAC;AAC5F;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,yBAAyB,CAChCD,SAAiB,EACjBE,MAAuD,EACvDC,YAAgB,EAChB;EACA,OAAO,YAAiB;IAAA,kCAAbC,IAAI;MAAJA,IAAI;IAAA;IACb,MAAMC,eAAe,GAAGH,MAAM,CAAC,GAAG,CAAC,GAAGC,YAAY,EAAE,GAAGC,IAAI,CAAC,CAAC;;IAE7D;IACA;IACA,IAAIC,eAAe,IAAIA,eAAe,CAACC,IAAI,EAAE;MAC3C,MAAMC,OAAO,GAAG,IAAIC,KAAK,EAAE,CAACC,KAAK,IAAI,EAAE;MACvC,OAAOJ,eAAe,CAACK,KAAK,CAACC,WAAW,IACtC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E,4BAAiB,CAAC,EAAE;IAC7C,OAAOnE,sBAAsB,CAACmE,4BAAiB,CAAC;EAClD;EAEA,MAAM3D,SAAS,GAAG,KAAK;EACvB,MAAMoC,YAAY,GAAGC,0BAAa,CAACsB,4BAAiB,CAAC;EAErD,IAAI,CAACvB,YAAY,EAAE;IACjB,MAAM,IAAI5B,KAAK,CAAC8B,wBAAwB,CAACtC,SAAS,CAAC,CAAC;EACtD;EAEAR,sBAAsB,CAACmE,4BAAiB,CAAC,GAAG5C,mBAAmB,CAACf,SAAS,EAAEoC,YAAY,EAAE,EAAE,CAAC;EAE5F,OAAO5C,sBAAsB,CAACmE,4BAAiB,CAAC;AAClD"}
1
+ {"version":3,"names":["NATIVE_MODULE_REGISTRY","NATIVE_MODULE_EVENT_SUBSCRIPTIONS","nativeModuleKey","module","_customUrlOrRegion","app","name","_config","namespace","nativeModuleMethodWrapped","method","argToPrepend","args","possiblePromise","then","jsStack","Error","stack","catch","nativeError","Promise","reject","NativeError","nativeModuleWrapped","NativeModule","native","properties","Object","keys","i","len","length","property","isFunction","initialiseNativeModule","config","key","nativeEvents","nativeModuleName","multiModuleRoot","multiModule","Array","isArray","nativeModuleNames","nativeModule","NativeModules","getMissingModuleHelpText","assign","subscribeToNativeModuleEvent","freeze","eventName","GoogleMobileAdsNativeEventEmitter","addListener","event","appName","SharedEventEmitter","emit","snippet","charAt","toUpperCase","slice","Platform","OS","rnPackage","newInstance","getNativeModule"],"sources":["nativeModule.ts"],"sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport { NativeModules, Platform } from 'react-native';\nimport { NativeError } from '../NativeError';\nimport { GoogleMobileAdsNativeEventEmitter } from '../GoogleMobileAdsNativeEventEmitter';\nimport { SharedEventEmitter } from '../SharedEventEmitter';\nimport { isFunction } from '../../common';\nimport { ModuleInterface } from '../../types/Module.interface';\n\nconst NATIVE_MODULE_REGISTRY: Record<string, unknown> = {};\nconst NATIVE_MODULE_EVENT_SUBSCRIPTIONS: Record<string, unknown> = {};\n\nfunction nativeModuleKey(module: ModuleInterface) {\n return `${module._customUrlOrRegion || ''}:${module.app.name}:${module._config.namespace}`;\n}\n\n/**\n * Wraps a native module method to provide\n * auto prepended args and custom Error classes.\n *\n * @param namespace\n * @param method\n * @param argToPrepend\n * @returns {Function}\n */\nfunction nativeModuleMethodWrapped(\n namespace: string,\n method: (...args: unknown[]) => Promise<unknown> | void,\n argToPrepend: [],\n) {\n return (...args: []) => {\n const possiblePromise = method(...[...argToPrepend, ...args]);\n\n // @ts-ignore -- return type is Promise, so tsc infers we *know* it is a promise and .then always exists, but\n // but the typing is actually speculative, we do need to test it\n if (possiblePromise && possiblePromise.then) {\n const jsStack = new Error().stack || '';\n return possiblePromise.catch(nativeError =>\n Promise.reject(new NativeError(nativeError, jsStack, namespace)),\n );\n }\n\n return possiblePromise;\n };\n}\n\n/**\n * Prepends all arguments in prependArgs to all native method calls\n *\n * @param namespace\n * @param NativeModule\n * @param argToPrepend\n */\nfunction nativeModuleWrapped(\n namespace: string,\n NativeModule: Record<string, (...args: unknown[]) => Promise<unknown> | void>,\n argToPrepend: [],\n) {\n const native: Record<string, unknown> = {};\n if (!NativeModule) {\n return NativeModule;\n }\n\n const properties = Object.keys(NativeModule);\n\n for (let i = 0, len = properties.length; i < len; i++) {\n const property = properties[i];\n if (isFunction(NativeModule[property])) {\n native[property] = nativeModuleMethodWrapped(namespace, NativeModule[property], argToPrepend);\n } else {\n native[property] = NativeModule[property];\n }\n }\n\n return native;\n}\n\n/**\n * Initialises and wraps all the native module methods.\n *\n * @param module\n * @returns {*}\n */\nfunction initialiseNativeModule(module: ModuleInterface) {\n const config = module._config;\n const key = nativeModuleKey(module);\n const { namespace, nativeEvents, nativeModuleName } = config;\n const multiModuleRoot: Record<string, unknown> = {};\n const multiModule = Array.isArray(nativeModuleName);\n const nativeModuleNames = multiModule ? nativeModuleName : [nativeModuleName];\n\n for (let i = 0; i < nativeModuleNames.length; i++) {\n const nativeModule = NativeModules[nativeModuleNames[i]];\n\n // only error if there's a single native module\n // as multi modules can mean some are optional\n if (!multiModule && !nativeModule) {\n throw new Error(getMissingModuleHelpText(namespace));\n }\n\n if (multiModule) {\n multiModuleRoot[nativeModuleNames[i]] = !!nativeModule;\n }\n\n Object.assign(multiModuleRoot, nativeModuleWrapped(namespace, nativeModule, []));\n }\n\n if (nativeEvents && nativeEvents.length) {\n for (let i = 0, len = nativeEvents.length; i < len; i++) {\n subscribeToNativeModuleEvent(nativeEvents[i]);\n }\n }\n\n Object.freeze(multiModuleRoot);\n\n NATIVE_MODULE_REGISTRY[key] = multiModuleRoot;\n\n return NATIVE_MODULE_REGISTRY[key];\n}\n\n/**\n * Subscribe to a native event for js side distribution by appName\n * React Native events are hard set at compile - cant do dynamic event names\n * so we use a single event send it to js and js then internally can prefix it\n * and distribute dynamically.\n *\n * @param eventName\n * @private\n */\nfunction subscribeToNativeModuleEvent(eventName: string) {\n if (!NATIVE_MODULE_EVENT_SUBSCRIPTIONS[eventName]) {\n GoogleMobileAdsNativeEventEmitter.addListener(eventName, event => {\n if (event.appName) {\n // native event has an appName property - auto prefix and internally emit\n SharedEventEmitter.emit(`${event.appName}-${eventName}`, event);\n } else {\n // standard event - no need to prefix\n SharedEventEmitter.emit(eventName, event);\n }\n });\n\n NATIVE_MODULE_EVENT_SUBSCRIPTIONS[eventName] = true;\n }\n}\n\n/**\n * Help text for integrating the native counter parts for each module.\n *\n * @param namespace\n * @returns {string}\n */\nfunction getMissingModuleHelpText(namespace: string) {\n const snippet = `${namespace}()`;\n const nativeModule = namespace.charAt(0).toUpperCase() + namespace.slice(1);\n\n if (Platform.OS === 'ios') {\n return (\n `You attempted to use a module that's not installed natively on your iOS project by calling ${snippet}.` +\n '\\r\\n\\r\\nEnsure you have either linked the module or added it to your projects Podfile.' +\n '\\r\\n\\r\\nSee http://invertase.link/ios for full setup instructions.'\n );\n }\n\n const rnPackage = `'io.invertase.${namespace}.ReactNative${nativeModule}Package'`;\n const newInstance = `'new ReactNative${nativeModule}Package()'`;\n\n return (\n `You attempted to use a module that's not installed on your Android project by calling ${snippet}.` +\n `\\r\\n\\r\\nEnsure you have:\\r\\n\\r\\n1) imported the ${rnPackage} module in your 'MainApplication.java' file.\\r\\n\\r\\n2) Added the ` +\n `${newInstance} line inside of the RN 'getPackages()' method list.` +\n '\\r\\n\\r\\nSee http://invertase.link/android for full setup instructions.'\n );\n}\n\n/**\n * Gets a wrapped native module instance for the provided module.\n * Will attempt to create a new instance if non previously created.\n *\n * @param module\n * @returns {*}\n */\nexport function getNativeModule(module: ModuleInterface) {\n const key = nativeModuleKey(module);\n\n if (NATIVE_MODULE_REGISTRY[key]) {\n return NATIVE_MODULE_REGISTRY[key];\n }\n\n return initialiseNativeModule(module);\n}\n"],"mappings":";;;;;;AAiBA;AACA;AACA;AACA;AACA;AArBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,MAAMA,sBAA+C,GAAG,CAAC,CAAC;AAC1D,MAAMC,iCAA0D,GAAG,CAAC,CAAC;AAErE,SAASC,eAAe,CAACC,MAAuB,EAAE;EAChD,OAAQ,GAAEA,MAAM,CAACC,kBAAkB,IAAI,EAAG,IAAGD,MAAM,CAACE,GAAG,CAACC,IAAK,IAAGH,MAAM,CAACI,OAAO,CAACC,SAAU,EAAC;AAC5F;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,yBAAyB,CAChCD,SAAiB,EACjBE,MAAuD,EACvDC,YAAgB,EAChB;EACA,O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AACA;AACA;AACO,SAASC,eAAe,CAAC9D,MAAuB,EAAE;EACvD,MAAMiC,GAAG,GAAGlC,eAAe,CAACC,MAAM,CAAC;EAEnC,IAAIH,sBAAsB,CAACoC,GAAG,CAAC,EAAE;IAC/B,OAAOpC,sBAAsB,CAACoC,GAAG,CAAC;EACpC;EAEA,OAAOF,sBAAsB,CAAC/B,MAAM,CAAC;AACvC"}
@@ -5,6 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = void 0;
7
7
  // Generated by genversion.
8
- const version = '8.1.2';
8
+ const version = '8.2.0';
9
9
  exports.version = version;
10
10
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["version"],"sources":["version.ts"],"sourcesContent":["// Generated by genversion.\nexport const version = '8.1.2';\n"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAO;AAAC"}
1
+ {"version":3,"names":["version"],"sources":["version.ts"],"sourcesContent":["// Generated by genversion.\nexport const version = '8.2.0';\n"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAO;AAAC"}
@@ -70,6 +70,10 @@ export class MobileAd {
70
70
  this._loaded = false;
71
71
  this._isLoadCalled = false;
72
72
  }
73
+ if (type === AdEventType.ERROR) {
74
+ this._loaded = false;
75
+ this._isLoadCalled = false;
76
+ }
73
77
  let payload = data;
74
78
  if (error) {
75
79
  payload = NativeError.fromEvent(error, 'googleMobileAds');
@@ -1 +1 @@
1
- {"version":3,"names":["isFunction","isOneOf","NativeError","AdEventType","RewardedAdEventType","GAMAdEventType","validateAdShowOptions","MobileAd","constructor","type","googleMobileAds","requestId","adUnitId","requestOptions","_type","_googleMobileAds","_requestId","_adUnitId","_requestOptions","_loaded","_isLoadCalled","_adEventsListeners","Map","_adEventListenersMap","Object","values","_","LOADED","forEach","set","_adEventListenerId","_adEventsListenerId","_nativeListener","emitter","addListener","_handleAdEvent","bind","event","error","data","body","CLOSED","payload","fromEvent","listener","_getAdEventListeners","_addAdEventsListener","Error","_className","id","delete","_addAdEventListener","get","name","_camelCaseType","load","native","show","showOptions","options","e","message","removeAllListeners","clear","map","loaded"],"sources":["MobileAd.ts"],"sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport { EmitterSubscription } from 'react-native';\nimport { isFunction, isOneOf } from '../common';\nimport { NativeError } from '../internal/NativeError';\nimport { AdEventType } from '../AdEventType';\nimport { RewardedAdEventType } from '../RewardedAdEventType';\nimport { AdEventListener, AdEventPayload } from '../types/AdEventListener';\nimport { AdEventsListener } from '../types/AdEventsListener';\nimport { AdShowOptions } from '../types/AdShowOptions';\nimport { RequestOptions } from '../types/RequestOptions';\nimport { MobileAdInterface } from '../types/MobileAd.interface';\nimport { MobileAdsModuleInterface } from '../types/MobileAdsModule.interface';\nimport { RewardedAdReward } from '../types/RewardedAdReward';\nimport { GAMAdEventType } from '../GAMAdEventType';\nimport { AppEvent } from '../types/AppEvent';\nimport { validateAdShowOptions } from '../validateAdShowOptions';\n\ntype EventType = AdEventType | RewardedAdEventType | GAMAdEventType;\n\nexport abstract class MobileAd implements MobileAdInterface {\n protected _type: 'app_open' | 'interstitial' | 'rewarded' | 'rewarded_interstitial';\n protected _googleMobileAds: MobileAdsModuleInterface;\n protected _requestId: number;\n protected _adUnitId: string;\n protected _requestOptions: RequestOptions;\n protected _loaded: boolean;\n protected _isLoadCalled: boolean;\n protected _adEventsListeners: Map<number, AdEventsListener<EventType>>;\n protected _adEventListenersMap: Map<EventType, Map<number, AdEventListener<EventType>>>;\n protected _adEventsListenerId: number;\n protected _adEventListenerId: number;\n protected _nativeListener: EmitterSubscription;\n\n protected constructor(\n type: 'app_open' | 'interstitial' | 'rewarded' | 'rewarded_interstitial',\n googleMobileAds: MobileAdsModuleInterface,\n requestId: number,\n adUnitId: string,\n requestOptions: RequestOptions,\n ) {\n this._type = type;\n this._googleMobileAds = googleMobileAds;\n this._requestId = requestId;\n this._adUnitId = adUnitId;\n this._requestOptions = requestOptions;\n\n this._loaded = false;\n this._isLoadCalled = false;\n this._adEventsListeners = new Map();\n this._adEventListenersMap = new Map();\n Object.values({\n ...AdEventType,\n ...RewardedAdEventType,\n ...GAMAdEventType,\n _: AdEventType.LOADED, // since AdEventType.LOADED is overwritten by RewardedAdEventType.LOADED\n }).forEach(type => {\n this._adEventListenersMap.set(type as EventType, new Map());\n });\n this._adEventListenerId = 0;\n this._adEventsListenerId = 0;\n\n this._nativeListener = googleMobileAds.emitter.addListener(\n `google_mobile_ads_${type}_event:${adUnitId}:${requestId}`,\n this._handleAdEvent.bind(this),\n );\n }\n\n protected _handleAdEvent(event: {\n body: {\n type: EventType;\n error?: { code: string; message: string };\n data?: RewardedAdReward | AppEvent;\n };\n }) {\n const { type, error, data } = event.body;\n\n if (type === AdEventType.LOADED || type === RewardedAdEventType.LOADED) {\n this._loaded = true;\n }\n\n if (type === AdEventType.CLOSED) {\n this._loaded = false;\n this._isLoadCalled = false;\n }\n\n let payload: AdEventPayload<EventType> = data;\n if (error) {\n payload = NativeError.fromEvent(error, 'googleMobileAds');\n }\n this._adEventsListeners.forEach(listener => {\n listener({\n type,\n payload,\n });\n });\n this._getAdEventListeners(type).forEach(listener => {\n listener(payload);\n });\n }\n\n protected _addAdEventsListener<T extends EventType>(listener: AdEventsListener<T>) {\n if (!isFunction(listener)) {\n throw new Error(`${this._className}.addAdEventsListener(*) 'listener' expected a function.`);\n }\n\n const id = this._adEventsListenerId++;\n this._adEventsListeners.set(id, listener as AdEventsListener<EventType>);\n return () => {\n this._adEventsListeners.delete(id);\n };\n }\n\n protected _addAdEventListener<T extends EventType>(type: T, listener: AdEventListener<T>) {\n if (\n !(\n isOneOf(type, Object.values(AdEventType)) ||\n (isOneOf(type, Object.values(RewardedAdEventType)) &&\n (this._type === 'rewarded' || this._type === 'rewarded_interstitial'))\n )\n ) {\n throw new Error(\n `${this._className}.addAdEventListener(*) 'type' expected a valid event type value.`,\n );\n }\n if (!isFunction(listener)) {\n throw new Error(\n `${this._className}.addAdEventListener(_, *) 'listener' expected a function.`,\n );\n }\n\n const id = this._adEventListenerId++;\n this._getAdEventListeners(type).set(id, listener);\n return () => {\n this._getAdEventListeners(type).delete(id);\n };\n }\n\n protected _getAdEventListeners<T extends EventType>(type: T) {\n return this._adEventListenersMap.get(type) as Map<number, AdEventListener<T>>;\n }\n\n protected get _className() {\n return this.constructor.name;\n }\n\n protected get _camelCaseType() {\n let type: 'appOpen' | 'interstitial' | 'rewarded' | 'rewardedInterstitial';\n if (this._type === 'app_open') {\n type = 'appOpen';\n } else if (this._type === 'rewarded_interstitial') {\n type = 'rewardedInterstitial';\n } else {\n type = this._type;\n }\n return type;\n }\n\n public load() {\n // Prevent multiple load calls\n if (this._loaded || this._isLoadCalled) {\n return;\n }\n\n this._isLoadCalled = true;\n const load = this._googleMobileAds.native[`${this._camelCaseType}Load`];\n load(this._requestId, this._adUnitId, this._requestOptions);\n }\n\n public show(showOptions?: AdShowOptions) {\n if (!this._loaded) {\n throw new Error(\n `${this._className}.show() The requested ${this._className} has not loaded and could not be shown.`,\n );\n }\n\n let options;\n try {\n options = validateAdShowOptions(showOptions);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`${this._className}.show(*) ${e.message}.`);\n } else {\n throw e;\n }\n }\n\n const show = this._googleMobileAds.native[`${this._camelCaseType}Show`];\n return show(this._requestId, this._adUnitId, options);\n }\n\n public abstract addAdEventsListener<T extends never>(listener: AdEventsListener<T>): () => void;\n\n public abstract addAdEventListener<T extends never>(type: T, listener: AdEventListener<T>): void;\n\n public removeAllListeners() {\n this._adEventsListeners.clear();\n this._adEventListenersMap.forEach((_, type, map) => {\n map.set(type, new Map());\n });\n }\n\n public get adUnitId() {\n return this._adUnitId;\n }\n\n public get loaded() {\n return this._loaded;\n }\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,UAAU,EAAEC,OAAO,QAAQ,WAAW;AAC/C,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,mBAAmB,QAAQ,wBAAwB;AAQ5D,SAASC,cAAc,QAAQ,mBAAmB;AAElD,SAASC,qBAAqB,QAAQ,0BAA0B;AAIhE,OAAO,MAAeC,QAAQ,CAA8B;EAchDC,WAAW,CACnBC,IAAwE,EACxEC,eAAyC,EACzCC,SAAiB,EACjBC,QAAgB,EAChBC,cAA8B,EAC9B;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IACA,IAAI,CAACC,KAAK,GAAGL,IAAI;IACjB,IAAI,CAACM,gBAAgB,GAAGL,eAAe;IACvC,IAAI,CAACM,UAAU,GAAGL,SAAS;IAC3B,IAAI,CAACM,SAAS,GAAGL,QAAQ;IACzB,IAAI,CAACM,eAAe,GAAGL,cAAc;IAErC,IAAI,CAACM,OAAO,GAAG,KAAK;IACpB,IAAI,CAACC,aAAa,GAAG,KAAK;IAC1B,IAAI,CAACC,kBAAkB,GAAG,IAAIC,GAAG,EAAE;IACnC,IAAI,CAACC,oBAAoB,GAAG,IAAID,GAAG,EAAE;IACrCE,MAAM,CAACC,MAAM,CAAC;MACZ,GAAGtB,WAAW;MACd,GAAGC,mBAAmB;MACtB,GAAGC,cAAc;MACjBqB,CAAC,EAAEvB,WAAW,CAACwB,MAAM,CAAE;IACzB,CAAC,CAAC,CAACC,OAAO,CAACnB,IAAI,IAAI;MACjB,IAAI,CAACc,oBAAoB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e,MAAK,CAAC;IACvE,OAAOG,IAAI,CAAC,IAAI,CAACzC,UAAU,EAAE,IAAI,CAACC,SAAS,EAAE0C,OAAO,CAAC;EACvD;EAMOG,kBAAkB,GAAG;IAC1B,IAAI,CAACzC,kBAAkB,CAAC0C,KAAK,EAAE;IAC/B,IAAI,CAACxC,oBAAoB,CAACK,OAAO,CAAC,CAACF,CAAC,EAAEjB,IAAI,EAAEuD,GAAG,KAAK;MAClDA,GAAG,CAACnC,GAAG,CAACpB,IAAI,EAAE,IAAIa,GAAG,EAAE,CAAC;IAC1B,CAAC,CAAC;EACJ;EAEA,IAAWV,QAAQ,GAAG;IACpB,OAAO,IAAI,CAACK,SAAS;EACvB;EAEA,IAAWgD,MAAM,GAAG;IAClB,OAAO,IAAI,CAAC9C,OAAO;EACrB;AACF"}
1
+ {"version":3,"names":["isFunction","isOneOf","NativeError","AdEventType","RewardedAdEventType","GAMAdEventType","validateAdShowOptions","MobileAd","constructor","type","googleMobileAds","requestId","adUnitId","requestOptions","_type","_googleMobileAds","_requestId","_adUnitId","_requestOptions","_loaded","_isLoadCalled","_adEventsListeners","Map","_adEventListenersMap","Object","values","_","LOADED","forEach","set","_adEventListenerId","_adEventsListenerId","_nativeListener","emitter","addListener","_handleAdEvent","bind","event","error","data","body","CLOSED","ERROR","payload","fromEvent","listener","_getAdEventListeners","_addAdEventsListener","Error","_className","id","delete","_addAdEventListener","get","name","_camelCaseType","load","native","show","showOptions","options","e","message","removeAllListeners","clear","map","loaded"],"sources":["MobileAd.ts"],"sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport { EmitterSubscription } from 'react-native';\nimport { isFunction, isOneOf } from '../common';\nimport { NativeError } from '../internal/NativeError';\nimport { AdEventType } from '../AdEventType';\nimport { RewardedAdEventType } from '../RewardedAdEventType';\nimport { AdEventListener, AdEventPayload } from '../types/AdEventListener';\nimport { AdEventsListener } from '../types/AdEventsListener';\nimport { AdShowOptions } from '../types/AdShowOptions';\nimport { RequestOptions } from '../types/RequestOptions';\nimport { MobileAdInterface } from '../types/MobileAd.interface';\nimport { MobileAdsModuleInterface } from '../types/MobileAdsModule.interface';\nimport { RewardedAdReward } from '../types/RewardedAdReward';\nimport { GAMAdEventType } from '../GAMAdEventType';\nimport { AppEvent } from '../types/AppEvent';\nimport { validateAdShowOptions } from '../validateAdShowOptions';\n\ntype EventType = AdEventType | RewardedAdEventType | GAMAdEventType;\n\nexport abstract class MobileAd implements MobileAdInterface {\n protected _type: 'app_open' | 'interstitial' | 'rewarded' | 'rewarded_interstitial';\n protected _googleMobileAds: MobileAdsModuleInterface;\n protected _requestId: number;\n protected _adUnitId: string;\n protected _requestOptions: RequestOptions;\n protected _loaded: boolean;\n protected _isLoadCalled: boolean;\n protected _adEventsListeners: Map<number, AdEventsListener<EventType>>;\n protected _adEventListenersMap: Map<EventType, Map<number, AdEventListener<EventType>>>;\n protected _adEventsListenerId: number;\n protected _adEventListenerId: number;\n protected _nativeListener: EmitterSubscription;\n\n protected constructor(\n type: 'app_open' | 'interstitial' | 'rewarded' | 'rewarded_interstitial',\n googleMobileAds: MobileAdsModuleInterface,\n requestId: number,\n adUnitId: string,\n requestOptions: RequestOptions,\n ) {\n this._type = type;\n this._googleMobileAds = googleMobileAds;\n this._requestId = requestId;\n this._adUnitId = adUnitId;\n this._requestOptions = requestOptions;\n\n this._loaded = false;\n this._isLoadCalled = false;\n this._adEventsListeners = new Map();\n this._adEventListenersMap = new Map();\n Object.values({\n ...AdEventType,\n ...RewardedAdEventType,\n ...GAMAdEventType,\n _: AdEventType.LOADED, // since AdEventType.LOADED is overwritten by RewardedAdEventType.LOADED\n }).forEach(type => {\n this._adEventListenersMap.set(type as EventType, new Map());\n });\n this._adEventListenerId = 0;\n this._adEventsListenerId = 0;\n\n this._nativeListener = googleMobileAds.emitter.addListener(\n `google_mobile_ads_${type}_event:${adUnitId}:${requestId}`,\n this._handleAdEvent.bind(this),\n );\n }\n\n protected _handleAdEvent(event: {\n body: {\n type: EventType;\n error?: { code: string; message: string };\n data?: RewardedAdReward | AppEvent;\n };\n }) {\n const { type, error, data } = event.body;\n\n if (type === AdEventType.LOADED || type === RewardedAdEventType.LOADED) {\n this._loaded = true;\n }\n\n if (type === AdEventType.CLOSED) {\n this._loaded = false;\n this._isLoadCalled = false;\n }\n\n if (type === AdEventType.ERROR) {\n this._loaded = false;\n this._isLoadCalled = false;\n }\n\n let payload: AdEventPayload<EventType> = data;\n if (error) {\n payload = NativeError.fromEvent(error, 'googleMobileAds');\n }\n this._adEventsListeners.forEach(listener => {\n listener({\n type,\n payload,\n });\n });\n this._getAdEventListeners(type).forEach(listener => {\n listener(payload);\n });\n }\n\n protected _addAdEventsListener<T extends EventType>(listener: AdEventsListener<T>) {\n if (!isFunction(listener)) {\n throw new Error(`${this._className}.addAdEventsListener(*) 'listener' expected a function.`);\n }\n\n const id = this._adEventsListenerId++;\n this._adEventsListeners.set(id, listener as AdEventsListener<EventType>);\n return () => {\n this._adEventsListeners.delete(id);\n };\n }\n\n protected _addAdEventListener<T extends EventType>(type: T, listener: AdEventListener<T>) {\n if (\n !(\n isOneOf(type, Object.values(AdEventType)) ||\n (isOneOf(type, Object.values(RewardedAdEventType)) &&\n (this._type === 'rewarded' || this._type === 'rewarded_interstitial'))\n )\n ) {\n throw new Error(\n `${this._className}.addAdEventListener(*) 'type' expected a valid event type value.`,\n );\n }\n if (!isFunction(listener)) {\n throw new Error(\n `${this._className}.addAdEventListener(_, *) 'listener' expected a function.`,\n );\n }\n\n const id = this._adEventListenerId++;\n this._getAdEventListeners(type).set(id, listener);\n return () => {\n this._getAdEventListeners(type).delete(id);\n };\n }\n\n protected _getAdEventListeners<T extends EventType>(type: T) {\n return this._adEventListenersMap.get(type) as Map<number, AdEventListener<T>>;\n }\n\n protected get _className() {\n return this.constructor.name;\n }\n\n protected get _camelCaseType() {\n let type: 'appOpen' | 'interstitial' | 'rewarded' | 'rewardedInterstitial';\n if (this._type === 'app_open') {\n type = 'appOpen';\n } else if (this._type === 'rewarded_interstitial') {\n type = 'rewardedInterstitial';\n } else {\n type = this._type;\n }\n return type;\n }\n\n public load() {\n // Prevent multiple load calls\n if (this._loaded || this._isLoadCalled) {\n return;\n }\n\n this._isLoadCalled = true;\n const load = this._googleMobileAds.native[`${this._camelCaseType}Load`];\n load(this._requestId, this._adUnitId, this._requestOptions);\n }\n\n public show(showOptions?: AdShowOptions) {\n if (!this._loaded) {\n throw new Error(\n `${this._className}.show() The requested ${this._className} has not loaded and could not be shown.`,\n );\n }\n\n let options;\n try {\n options = validateAdShowOptions(showOptions);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`${this._className}.show(*) ${e.message}.`);\n } else {\n throw e;\n }\n }\n\n const show = this._googleMobileAds.native[`${this._camelCaseType}Show`];\n return show(this._requestId, this._adUnitId, options);\n }\n\n public abstract addAdEventsListener<T extends never>(listener: AdEventsListener<T>): () => void;\n\n public abstract addAdEventListener<T extends never>(type: T, listener: AdEventListener<T>): void;\n\n public removeAllListeners() {\n this._adEventsListeners.clear();\n this._adEventListenersMap.forEach((_, type, map) => {\n map.set(type, new Map());\n });\n }\n\n public get adUnitId() {\n return this._adUnitId;\n }\n\n public get loaded() {\n return this._loaded;\n }\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,UAAU,EAAEC,OAAO,QAAQ,WAAW;AAC/C,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAAS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AACK,OAAO,CAAC,CAACF,CAAC,EAAEjB,IAAI,EAAEwD,GAAG,KAAK;MAClDA,GAAG,CAACpC,GAAG,CAACpB,IAAI,EAAE,IAAIa,GAAG,EAAE,CAAC;IAC1B,CAAC,CAAC;EACJ;EAEA,IAAWV,QAAQ,GAAG;IACpB,OAAO,IAAI,CAACK,SAAS;EACvB;EAEA,IAAWiD,MAAM,GAAG;IAClB,OAAO,IAAI,CAAC/C,OAAO;EACrB;AACF"}
@@ -16,7 +16,6 @@
16
16
  */
17
17
 
18
18
  import { NativeModules, Platform } from 'react-native';
19
- import { APP_NATIVE_MODULE } from '../constants';
20
19
  import { NativeError } from '../NativeError';
21
20
  import { GoogleMobileAdsNativeEventEmitter } from '../GoogleMobileAdsNativeEventEmitter';
22
21
  import { SharedEventEmitter } from '../SharedEventEmitter';
@@ -172,22 +171,4 @@ export function getNativeModule(module) {
172
171
  }
173
172
  return initialiseNativeModule(module);
174
173
  }
175
-
176
- /**
177
- * Custom wrapped app module as it does not have it's own FirebaseModule based class.
178
- *
179
- * @returns {*}
180
- */
181
- export function getAppModule() {
182
- if (NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE]) {
183
- return NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE];
184
- }
185
- const namespace = 'app';
186
- const nativeModule = NativeModules[APP_NATIVE_MODULE];
187
- if (!nativeModule) {
188
- throw new Error(getMissingModuleHelpText(namespace));
189
- }
190
- NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE] = nativeModuleWrapped(namespace, nativeModule, []);
191
- return NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE];
192
- }
193
174
  //# sourceMappingURL=nativeModule.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","Platform","APP_NATIVE_MODULE","NativeError","GoogleMobileAdsNativeEventEmitter","SharedEventEmitter","isFunction","NATIVE_MODULE_REGISTRY","NATIVE_MODULE_EVENT_SUBSCRIPTIONS","nativeModuleKey","module","_customUrlOrRegion","app","name","_config","namespace","nativeModuleMethodWrapped","method","argToPrepend","args","possiblePromise","then","jsStack","Error","stack","catch","nativeError","Promise","reject","nativeModuleWrapped","NativeModule","native","properties","Object","keys","i","len","length","property","initialiseNativeModule","config","key","nativeEvents","nativeModuleName","multiModuleRoot","multiModule","Array","isArray","nativeModuleNames","nativeModule","getMissingModuleHelpText","assign","subscribeToNativeModuleEvent","freeze","eventName","addListener","event","appName","emit","snippet","charAt","toUpperCase","slice","OS","rnPackage","newInstance","getNativeModule","getAppModule"],"sources":["nativeModule.ts"],"sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport { NativeModules, Platform } from 'react-native';\nimport { APP_NATIVE_MODULE } from '../constants';\nimport { NativeError } from '../NativeError';\nimport { GoogleMobileAdsNativeEventEmitter } from '../GoogleMobileAdsNativeEventEmitter';\nimport { SharedEventEmitter } from '../SharedEventEmitter';\nimport { isFunction } from '../../common';\nimport { ModuleInterface } from '../../types/Module.interface';\n\nconst NATIVE_MODULE_REGISTRY: Record<string, unknown> = {};\nconst NATIVE_MODULE_EVENT_SUBSCRIPTIONS: Record<string, unknown> = {};\n\nfunction nativeModuleKey(module: ModuleInterface) {\n return `${module._customUrlOrRegion || ''}:${module.app.name}:${module._config.namespace}`;\n}\n\n/**\n * Wraps a native module method to provide\n * auto prepended args and custom Error classes.\n *\n * @param namespace\n * @param method\n * @param argToPrepend\n * @returns {Function}\n */\nfunction nativeModuleMethodWrapped(\n namespace: string,\n method: (...args: unknown[]) => Promise<unknown> | void,\n argToPrepend: [],\n) {\n return (...args: []) => {\n const possiblePromise = method(...[...argToPrepend, ...args]);\n\n // @ts-ignore -- return type is Promise, so tsc infers we *know* it is a promise and .then always exists, but\n // but the typing is actually speculative, we do need to test it\n if (possiblePromise && possiblePromise.then) {\n const jsStack = new Error().stack || '';\n return possiblePromise.catch(nativeError =>\n Promise.reject(new NativeError(nativeError, jsStack, namespace)),\n );\n }\n\n return possiblePromise;\n };\n}\n\n/**\n * Prepends all arguments in prependArgs to all native method calls\n *\n * @param namespace\n * @param NativeModule\n * @param argToPrepend\n */\nfunction nativeModuleWrapped(\n namespace: string,\n NativeModule: Record<string, (...args: unknown[]) => Promise<unknown> | void>,\n argToPrepend: [],\n) {\n const native: Record<string, unknown> = {};\n if (!NativeModule) {\n return NativeModule;\n }\n\n const properties = Object.keys(NativeModule);\n\n for (let i = 0, len = properties.length; i < len; i++) {\n const property = properties[i];\n if (isFunction(NativeModule[property])) {\n native[property] = nativeModuleMethodWrapped(namespace, NativeModule[property], argToPrepend);\n } else {\n native[property] = NativeModule[property];\n }\n }\n\n return native;\n}\n\n/**\n * Initialises and wraps all the native module methods.\n *\n * @param module\n * @returns {*}\n */\nfunction initialiseNativeModule(module: ModuleInterface) {\n const config = module._config;\n const key = nativeModuleKey(module);\n const { namespace, nativeEvents, nativeModuleName } = config;\n const multiModuleRoot: Record<string, unknown> = {};\n const multiModule = Array.isArray(nativeModuleName);\n const nativeModuleNames = multiModule ? nativeModuleName : [nativeModuleName];\n\n for (let i = 0; i < nativeModuleNames.length; i++) {\n const nativeModule = NativeModules[nativeModuleNames[i]];\n\n // only error if there's a single native module\n // as multi modules can mean some are optional\n if (!multiModule && !nativeModule) {\n throw new Error(getMissingModuleHelpText(namespace));\n }\n\n if (multiModule) {\n multiModuleRoot[nativeModuleNames[i]] = !!nativeModule;\n }\n\n Object.assign(multiModuleRoot, nativeModuleWrapped(namespace, nativeModule, []));\n }\n\n if (nativeEvents && nativeEvents.length) {\n for (let i = 0, len = nativeEvents.length; i < len; i++) {\n subscribeToNativeModuleEvent(nativeEvents[i]);\n }\n }\n\n Object.freeze(multiModuleRoot);\n\n NATIVE_MODULE_REGISTRY[key] = multiModuleRoot;\n\n return NATIVE_MODULE_REGISTRY[key];\n}\n\n/**\n * Subscribe to a native event for js side distribution by appName\n * React Native events are hard set at compile - cant do dynamic event names\n * so we use a single event send it to js and js then internally can prefix it\n * and distribute dynamically.\n *\n * @param eventName\n * @private\n */\nfunction subscribeToNativeModuleEvent(eventName: string) {\n if (!NATIVE_MODULE_EVENT_SUBSCRIPTIONS[eventName]) {\n GoogleMobileAdsNativeEventEmitter.addListener(eventName, event => {\n if (event.appName) {\n // native event has an appName property - auto prefix and internally emit\n SharedEventEmitter.emit(`${event.appName}-${eventName}`, event);\n } else {\n // standard event - no need to prefix\n SharedEventEmitter.emit(eventName, event);\n }\n });\n\n NATIVE_MODULE_EVENT_SUBSCRIPTIONS[eventName] = true;\n }\n}\n\n/**\n * Help text for integrating the native counter parts for each module.\n *\n * @param namespace\n * @returns {string}\n */\nfunction getMissingModuleHelpText(namespace: string) {\n const snippet = `${namespace}()`;\n const nativeModule = namespace.charAt(0).toUpperCase() + namespace.slice(1);\n\n if (Platform.OS === 'ios') {\n return (\n `You attempted to use a module that's not installed natively on your iOS project by calling ${snippet}.` +\n '\\r\\n\\r\\nEnsure you have either linked the module or added it to your projects Podfile.' +\n '\\r\\n\\r\\nSee http://invertase.link/ios for full setup instructions.'\n );\n }\n\n const rnPackage = `'io.invertase.${namespace}.ReactNative${nativeModule}Package'`;\n const newInstance = `'new ReactNative${nativeModule}Package()'`;\n\n return (\n `You attempted to use a module that's not installed on your Android project by calling ${snippet}.` +\n `\\r\\n\\r\\nEnsure you have:\\r\\n\\r\\n1) imported the ${rnPackage} module in your 'MainApplication.java' file.\\r\\n\\r\\n2) Added the ` +\n `${newInstance} line inside of the RN 'getPackages()' method list.` +\n '\\r\\n\\r\\nSee http://invertase.link/android for full setup instructions.'\n );\n}\n\n/**\n * Gets a wrapped native module instance for the provided module.\n * Will attempt to create a new instance if non previously created.\n *\n * @param module\n * @returns {*}\n */\nexport function getNativeModule(module: ModuleInterface) {\n const key = nativeModuleKey(module);\n\n if (NATIVE_MODULE_REGISTRY[key]) {\n return NATIVE_MODULE_REGISTRY[key];\n }\n\n return initialiseNativeModule(module);\n}\n\n/**\n * Custom wrapped app module as it does not have it's own FirebaseModule based class.\n *\n * @returns {*}\n */\nexport function getAppModule() {\n if (NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE]) {\n return NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE];\n }\n\n const namespace = 'app';\n const nativeModule = NativeModules[APP_NATIVE_MODULE];\n\n if (!nativeModule) {\n throw new Error(getMissingModuleHelpText(namespace));\n }\n\n NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE] = nativeModuleWrapped(namespace, nativeModule, []);\n\n return NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AACtD,SAASC,iBAAiB,QAAQ,cAAc;AAChD,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,iCAAiC,QAAQ,sCAAsC;AACxF,SAASC,kBAAkB,QAAQ,uBAAuB;AAC1D,SAASC,UAAU,QAAQ,cAAc;AAGzC,MAAMC,sBAA+C,GAAG,CAAC,CAAC;AAC1D,MAAMC,iCAA0D,GAAG,CAAC,CAAC;AAErE,SAASC,eAAe,CAACC,MAAuB,EAAE;EAChD,OAAQ,GAAEA,MAAM,CAACC,kBAAkB,IAAI,EAAG,IAAGD,MAAM,CAACE,GAAG,CAACC,IAAK,IAAGH,MAAM,CAACI,OAAO,CAACC,SAAU,EAAC;AAC5F;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,yBAAyB,CAChCD,SAAiB,EACjBE,MAA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AAwE;AAE5E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAe,CAACxD,MAAuB,EAAE;EACvD,MAAM+B,GAAG,GAAGhC,eAAe,CAACC,MAAM,CAAC;EAEnC,IAAIH,sBAAsB,CAACkC,GAAG,CAAC,EAAE;IAC/B,OAAOlC,sBAAsB,CAACkC,GAAG,CAAC;EACpC;EAEA,OAAOF,sBAAsB,CAAC7B,MAAM,CAAC;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASyD,YAAY,GAAG;EAC7B,IAAI5D,sBAAsB,CAACL,iBAAiB,CAAC,EAAE;IAC7C,OAAOK,sBAAsB,CAACL,iBAAiB,CAAC;EAClD;EAEA,MAAMa,SAAS,GAAG,KAAK;EACvB,MAAMkC,YAAY,GAAGjD,aAAa,CAACE,iBAAiB,CAAC;EAErD,IAAI,CAAC+C,YAAY,EAAE;IACjB,MAAM,IAAI1B,KAAK,CAAC2B,wBAAwB,CAACnC,SAAS,CAAC,CAAC;EACtD;EAEAR,sBAAsB,CAACL,iBAAiB,CAAC,GAAG2B,mBAAmB,CAACd,SAAS,EAAEkC,YAAY,EAAE,EAAE,CAAC;EAE5F,OAAO1C,sBAAsB,CAACL,iBAAiB,CAAC;AAClD"}
1
+ {"version":3,"names":["NativeModules","Platform","NativeError","GoogleMobileAdsNativeEventEmitter","SharedEventEmitter","isFunction","NATIVE_MODULE_REGISTRY","NATIVE_MODULE_EVENT_SUBSCRIPTIONS","nativeModuleKey","module","_customUrlOrRegion","app","name","_config","namespace","nativeModuleMethodWrapped","method","argToPrepend","args","possiblePromise","then","jsStack","Error","stack","catch","nativeError","Promise","reject","nativeModuleWrapped","NativeModule","native","properties","Object","keys","i","len","length","property","initialiseNativeModule","config","key","nativeEvents","nativeModuleName","multiModuleRoot","multiModule","Array","isArray","nativeModuleNames","nativeModule","getMissingModuleHelpText","assign","subscribeToNativeModuleEvent","freeze","eventName","addListener","event","appName","emit","snippet","charAt","toUpperCase","slice","OS","rnPackage","newInstance","getNativeModule"],"sources":["nativeModule.ts"],"sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport { NativeModules, Platform } from 'react-native';\nimport { NativeError } from '../NativeError';\nimport { GoogleMobileAdsNativeEventEmitter } from '../GoogleMobileAdsNativeEventEmitter';\nimport { SharedEventEmitter } from '../SharedEventEmitter';\nimport { isFunction } from '../../common';\nimport { ModuleInterface } from '../../types/Module.interface';\n\nconst NATIVE_MODULE_REGISTRY: Record<string, unknown> = {};\nconst NATIVE_MODULE_EVENT_SUBSCRIPTIONS: Record<string, unknown> = {};\n\nfunction nativeModuleKey(module: ModuleInterface) {\n return `${module._customUrlOrRegion || ''}:${module.app.name}:${module._config.namespace}`;\n}\n\n/**\n * Wraps a native module method to provide\n * auto prepended args and custom Error classes.\n *\n * @param namespace\n * @param method\n * @param argToPrepend\n * @returns {Function}\n */\nfunction nativeModuleMethodWrapped(\n namespace: string,\n method: (...args: unknown[]) => Promise<unknown> | void,\n argToPrepend: [],\n) {\n return (...args: []) => {\n const possiblePromise = method(...[...argToPrepend, ...args]);\n\n // @ts-ignore -- return type is Promise, so tsc infers we *know* it is a promise and .then always exists, but\n // but the typing is actually speculative, we do need to test it\n if (possiblePromise && possiblePromise.then) {\n const jsStack = new Error().stack || '';\n return possiblePromise.catch(nativeError =>\n Promise.reject(new NativeError(nativeError, jsStack, namespace)),\n );\n }\n\n return possiblePromise;\n };\n}\n\n/**\n * Prepends all arguments in prependArgs to all native method calls\n *\n * @param namespace\n * @param NativeModule\n * @param argToPrepend\n */\nfunction nativeModuleWrapped(\n namespace: string,\n NativeModule: Record<string, (...args: unknown[]) => Promise<unknown> | void>,\n argToPrepend: [],\n) {\n const native: Record<string, unknown> = {};\n if (!NativeModule) {\n return NativeModule;\n }\n\n const properties = Object.keys(NativeModule);\n\n for (let i = 0, len = properties.length; i < len; i++) {\n const property = properties[i];\n if (isFunction(NativeModule[property])) {\n native[property] = nativeModuleMethodWrapped(namespace, NativeModule[property], argToPrepend);\n } else {\n native[property] = NativeModule[property];\n }\n }\n\n return native;\n}\n\n/**\n * Initialises and wraps all the native module methods.\n *\n * @param module\n * @returns {*}\n */\nfunction initialiseNativeModule(module: ModuleInterface) {\n const config = module._config;\n const key = nativeModuleKey(module);\n const { namespace, nativeEvents, nativeModuleName } = config;\n const multiModuleRoot: Record<string, unknown> = {};\n const multiModule = Array.isArray(nativeModuleName);\n const nativeModuleNames = multiModule ? nativeModuleName : [nativeModuleName];\n\n for (let i = 0; i < nativeModuleNames.length; i++) {\n const nativeModule = NativeModules[nativeModuleNames[i]];\n\n // only error if there's a single native module\n // as multi modules can mean some are optional\n if (!multiModule && !nativeModule) {\n throw new Error(getMissingModuleHelpText(namespace));\n }\n\n if (multiModule) {\n multiModuleRoot[nativeModuleNames[i]] = !!nativeModule;\n }\n\n Object.assign(multiModuleRoot, nativeModuleWrapped(namespace, nativeModule, []));\n }\n\n if (nativeEvents && nativeEvents.length) {\n for (let i = 0, len = nativeEvents.length; i < len; i++) {\n subscribeToNativeModuleEvent(nativeEvents[i]);\n }\n }\n\n Object.freeze(multiModuleRoot);\n\n NATIVE_MODULE_REGISTRY[key] = multiModuleRoot;\n\n return NATIVE_MODULE_REGISTRY[key];\n}\n\n/**\n * Subscribe to a native event for js side distribution by appName\n * React Native events are hard set at compile - cant do dynamic event names\n * so we use a single event send it to js and js then internally can prefix it\n * and distribute dynamically.\n *\n * @param eventName\n * @private\n */\nfunction subscribeToNativeModuleEvent(eventName: string) {\n if (!NATIVE_MODULE_EVENT_SUBSCRIPTIONS[eventName]) {\n GoogleMobileAdsNativeEventEmitter.addListener(eventName, event => {\n if (event.appName) {\n // native event has an appName property - auto prefix and internally emit\n SharedEventEmitter.emit(`${event.appName}-${eventName}`, event);\n } else {\n // standard event - no need to prefix\n SharedEventEmitter.emit(eventName, event);\n }\n });\n\n NATIVE_MODULE_EVENT_SUBSCRIPTIONS[eventName] = true;\n }\n}\n\n/**\n * Help text for integrating the native counter parts for each module.\n *\n * @param namespace\n * @returns {string}\n */\nfunction getMissingModuleHelpText(namespace: string) {\n const snippet = `${namespace}()`;\n const nativeModule = namespace.charAt(0).toUpperCase() + namespace.slice(1);\n\n if (Platform.OS === 'ios') {\n return (\n `You attempted to use a module that's not installed natively on your iOS project by calling ${snippet}.` +\n '\\r\\n\\r\\nEnsure you have either linked the module or added it to your projects Podfile.' +\n '\\r\\n\\r\\nSee http://invertase.link/ios for full setup instructions.'\n );\n }\n\n const rnPackage = `'io.invertase.${namespace}.ReactNative${nativeModule}Package'`;\n const newInstance = `'new ReactNative${nativeModule}Package()'`;\n\n return (\n `You attempted to use a module that's not installed on your Android project by calling ${snippet}.` +\n `\\r\\n\\r\\nEnsure you have:\\r\\n\\r\\n1) imported the ${rnPackage} module in your 'MainApplication.java' file.\\r\\n\\r\\n2) Added the ` +\n `${newInstance} line inside of the RN 'getPackages()' method list.` +\n '\\r\\n\\r\\nSee http://invertase.link/android for full setup instructions.'\n );\n}\n\n/**\n * Gets a wrapped native module instance for the provided module.\n * Will attempt to create a new instance if non previously created.\n *\n * @param module\n * @returns {*}\n */\nexport function getNativeModule(module: ModuleInterface) {\n const key = nativeModuleKey(module);\n\n if (NATIVE_MODULE_REGISTRY[key]) {\n return NATIVE_MODULE_REGISTRY[key];\n }\n\n return initialiseNativeModule(module);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,c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AAI,GAAE5C,SAAU,IAAG;EAChC,MAAMkC,YAAY,GAAGlC,SAAS,CAAC6C,MAAM,CAAC,CAAC,CAAC,CAACC,WAAW,EAAE,GAAG9C,SAAS,CAAC+C,KAAK,CAAC,CAAC,CAAC;EAE3E,IAAI5D,QAAQ,CAAC6D,EAAE,KAAK,KAAK,EAAE;IACzB,OACG,8FAA6FJ,OAAQ,GAAE,GACxG,wFAAwF,GACxF,oEAAoE;EAExE;EAEA,MAAMK,SAAS,GAAI,iBAAgBjD,SAAU,eAAckC,YAAa,UAAS;EACjF,MAAMgB,WAAW,GAAI,mBAAkBhB,YAAa,YAAW;EAE/D,OACG,yFAAwFU,OAAQ,GAAE,GAClG,mDAAkDK,SAAU,mEAAkE,GAC9H,GAAEC,WAAY,qDAAoD,GACnE,wEAAwE;AAE5E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAe,CAACxD,MAAuB,EAAE;EACvD,MAAM+B,GAAG,GAAGhC,eAAe,CAACC,MAAM,CAAC;EAEnC,IAAIH,sBAAsB,CAACkC,GAAG,CAAC,EAAE;IAC/B,OAAOlC,sBAAsB,CAACkC,GAAG,CAAC;EACpC;EAEA,OAAOF,sBAAsB,CAAC7B,MAAM,CAAC;AACvC"}
@@ -1,3 +1,3 @@
1
1
  // Generated by genversion.
2
- export const version = '8.1.2';
2
+ export const version = '8.2.0';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["version"],"sources":["version.ts"],"sourcesContent":["// Generated by genversion.\nexport const version = '8.1.2';\n"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAO"}
1
+ {"version":3,"names":["version"],"sources":["version.ts"],"sourcesContent":["// Generated by genversion.\nexport const version = '8.2.0';\n"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAO"}
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "8.1.2";
1
+ export declare const SDK_VERSION = "8.2.0";
2
2
  export { default, MobileAds } from './MobileAds';
3
3
  export { AdsConsentDebugGeography } from './AdsConsentDebugGeography';
4
4
  export { AdsConsentPurposes } from './AdsConsentPurposes';
@@ -7,9 +7,3 @@ import { ModuleInterface } from '../../types/Module.interface';
7
7
  * @returns {*}
8
8
  */
9
9
  export declare function getNativeModule(module: ModuleInterface): unknown;
10
- /**
11
- * Custom wrapped app module as it does not have it's own FirebaseModule based class.
12
- *
13
- * @returns {*}
14
- */
15
- export declare function getAppModule(): unknown;
@@ -1 +1 @@
1
- export declare const version = "8.1.2";
1
+ export declare const version = "8.2.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-google-mobile-ads",
3
- "version": "8.1.2",
3
+ "version": "8.2.0",
4
4
  "author": "Invertase <oss@invertase.io> (http://invertase.io)",
5
5
  "description": "React Native Google Mobile Ads is an easy way to monetize mobile apps with targeted, in-app advertising.",
6
6
  "main": "lib/commonjs/index.js",
@@ -99,6 +99,11 @@ export abstract class MobileAd implements MobileAdInterface {
99
99
  this._isLoadCalled = false;
100
100
  }
101
101
 
102
+ if (type === AdEventType.ERROR) {
103
+ this._loaded = false;
104
+ this._isLoadCalled = false;
105
+ }
106
+
102
107
  let payload: AdEventPayload<EventType> = data;
103
108
  if (error) {
104
109
  payload = NativeError.fromEvent(error, 'googleMobileAds');
@@ -16,7 +16,6 @@
16
16
  */
17
17
 
18
18
  import { NativeModules, Platform } from 'react-native';
19
- import { APP_NATIVE_MODULE } from '../constants';
20
19
  import { NativeError } from '../NativeError';
21
20
  import { GoogleMobileAdsNativeEventEmitter } from '../GoogleMobileAdsNativeEventEmitter';
22
21
  import { SharedEventEmitter } from '../SharedEventEmitter';
@@ -204,25 +203,3 @@ export function getNativeModule(module: ModuleInterface) {
204
203
 
205
204
  return initialiseNativeModule(module);
206
205
  }
207
-
208
- /**
209
- * Custom wrapped app module as it does not have it's own FirebaseModule based class.
210
- *
211
- * @returns {*}
212
- */
213
- export function getAppModule() {
214
- if (NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE]) {
215
- return NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE];
216
- }
217
-
218
- const namespace = 'app';
219
- const nativeModule = NativeModules[APP_NATIVE_MODULE];
220
-
221
- if (!nativeModule) {
222
- throw new Error(getMissingModuleHelpText(namespace));
223
- }
224
-
225
- NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE] = nativeModuleWrapped(namespace, nativeModule, []);
226
-
227
- return NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE];
228
- }
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '8.1.2';
2
+ export const version = '8.2.0';
@@ -1,30 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.KNOWN_NAMESPACES = exports.DEFAULT_APP_NAME = exports.APP_NATIVE_MODULE = void 0;
7
- /*
8
- * Copyright (c) 2016-present Invertase Limited & Contributors
9
- *
10
- * Licensed under the Apache License, Version 2.0 (the "License");
11
- * you may not use this library except in compliance with the License.
12
- * You may obtain a copy of the License at
13
- *
14
- * http://www.apache.org/licenses/LICENSE-2.0
15
- *
16
- * Unless required by applicable law or agreed to in writing, software
17
- * distributed under the License is distributed on an "AS IS" BASIS,
18
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
- * See the License for the specific language governing permissions and
20
- * limitations under the License.
21
- *
22
- */
23
-
24
- const APP_NATIVE_MODULE = 'RNFBAppModule';
25
- exports.APP_NATIVE_MODULE = APP_NATIVE_MODULE;
26
- const DEFAULT_APP_NAME = '[DEFAULT]';
27
- exports.DEFAULT_APP_NAME = DEFAULT_APP_NAME;
28
- const KNOWN_NAMESPACES = ['appCheck', 'appDistribution', 'auth', 'analytics', 'remoteConfig', 'crashlytics', 'database', 'inAppMessaging', 'installations', 'firestore', 'functions', 'indexing', 'storage', 'dynamicLinks', 'messaging', 'naturalLanguage', 'ml', 'notifications', 'perf', 'utils'];
29
- exports.KNOWN_NAMESPACES = KNOWN_NAMESPACES;
30
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["APP_NATIVE_MODULE","DEFAULT_APP_NAME","KNOWN_NAMESPACES"],"sources":["constants.ts"],"sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nexport const APP_NATIVE_MODULE = 'RNFBAppModule';\n\nexport const DEFAULT_APP_NAME = '[DEFAULT]';\n\nexport const KNOWN_NAMESPACES = [\n 'appCheck',\n 'appDistribution',\n 'auth',\n 'analytics',\n 'remoteConfig',\n 'crashlytics',\n 'database',\n 'inAppMessaging',\n 'installations',\n 'firestore',\n 'functions',\n 'indexing',\n 'storage',\n 'dynamicLinks',\n 'messaging',\n 'naturalLanguage',\n 'ml',\n 'notifications',\n 'perf',\n 'utils',\n];\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,MAAMA,iBAAiB,GAAG,eAAe;AAAC;AAE1C,MAAMC,gBAAgB,GAAG,WAAW;AAAC;AAErC,MAAMC,gBAAgB,GAAG,CAC9B,UAAU,EACV,iBAAiB,EACjB,MAAM,EACN,WAAW,EACX,cAAc,EACd,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,WAAW,EACX,UAAU,EACV,SAAS,EACT,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,IAAI,EACJ,eAAe,EACf,MAAM,EACN,OAAO,CACR;AAAC"}
@@ -1,21 +0,0 @@
1
- /*
2
- * Copyright (c) 2016-present Invertase Limited & Contributors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this library except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- *
16
- */
17
-
18
- export const APP_NATIVE_MODULE = 'RNFBAppModule';
19
- export const DEFAULT_APP_NAME = '[DEFAULT]';
20
- export const KNOWN_NAMESPACES = ['appCheck', 'appDistribution', 'auth', 'analytics', 'remoteConfig', 'crashlytics', 'database', 'inAppMessaging', 'installations', 'firestore', 'functions', 'indexing', 'storage', 'dynamicLinks', 'messaging', 'naturalLanguage', 'ml', 'notifications', 'perf', 'utils'];
21
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["APP_NATIVE_MODULE","DEFAULT_APP_NAME","KNOWN_NAMESPACES"],"sources":["constants.ts"],"sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nexport const APP_NATIVE_MODULE = 'RNFBAppModule';\n\nexport const DEFAULT_APP_NAME = '[DEFAULT]';\n\nexport const KNOWN_NAMESPACES = [\n 'appCheck',\n 'appDistribution',\n 'auth',\n 'analytics',\n 'remoteConfig',\n 'crashlytics',\n 'database',\n 'inAppMessaging',\n 'installations',\n 'firestore',\n 'functions',\n 'indexing',\n 'storage',\n 'dynamicLinks',\n 'messaging',\n 'naturalLanguage',\n 'ml',\n 'notifications',\n 'perf',\n 'utils',\n];\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMA,iBAAiB,GAAG,eAAe;AAEhD,OAAO,MAAMC,gBAAgB,GAAG,WAAW;AAE3C,OAAO,MAAMC,gBAAgB,GAAG,CAC9B,UAAU,EACV,iBAAiB,EACjB,MAAM,EACN,WAAW,EACX,cAAc,EACd,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,WAAW,EACX,UAAU,EACV,SAAS,EACT,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,IAAI,EACJ,eAAe,EACf,MAAM,EACN,OAAO,CACR"}
@@ -1,3 +0,0 @@
1
- export declare const APP_NATIVE_MODULE = "RNFBAppModule";
2
- export declare const DEFAULT_APP_NAME = "[DEFAULT]";
3
- export declare const KNOWN_NAMESPACES: string[];
@@ -1,43 +0,0 @@
1
- /*
2
- * Copyright (c) 2016-present Invertase Limited & Contributors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this library except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- *
16
- */
17
-
18
- export const APP_NATIVE_MODULE = 'RNFBAppModule';
19
-
20
- export const DEFAULT_APP_NAME = '[DEFAULT]';
21
-
22
- export const KNOWN_NAMESPACES = [
23
- 'appCheck',
24
- 'appDistribution',
25
- 'auth',
26
- 'analytics',
27
- 'remoteConfig',
28
- 'crashlytics',
29
- 'database',
30
- 'inAppMessaging',
31
- 'installations',
32
- 'firestore',
33
- 'functions',
34
- 'indexing',
35
- 'storage',
36
- 'dynamicLinks',
37
- 'messaging',
38
- 'naturalLanguage',
39
- 'ml',
40
- 'notifications',
41
- 'perf',
42
- 'utils',
43
- ];