Skip to content

Commit

Permalink
fix: incorrect module naming (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylancom authored Dec 3, 2021
1 parent 151f6aa commit 79f86b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/AdsConsent.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { NativeModules } from 'react-native';
import AdsConsentDebugGeography from './AdsConsentDebugGeography';
import AdsConsentStatus from './AdsConsentStatus';

const native = NativeModules.GoogleAdsConsentModule;
const native = NativeModules.RNGoogleAdsConsentModule;

export default {
/**
Expand Down
14 changes: 7 additions & 7 deletions lib/internal/GoogleAdsNativeEventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@

import { NativeEventEmitter, NativeModules } from 'react-native';

const { GoogleAdsModule } = NativeModules;
const { RNGoogleAdsModule } = NativeModules;

class GoogleAdsNativeEventEmitter extends NativeEventEmitter {
constructor() {
super(GoogleAdsModule);
super(RNGoogleAdsModule);
this.ready = false;
}

addListener(eventType, listener, context) {
if (!this.ready) {
GoogleAdsModule.eventsNotifyReady(true);
RNGoogleAdsModule.eventsNotifyReady(true);
this.ready = true;
}
GoogleAdsModule.eventsAddListener(eventType);
RNGoogleAdsModule.eventsAddListener(eventType);

let subscription = super.addListener(`google_ads_${eventType}`, listener, context);

Expand All @@ -45,7 +45,7 @@ class GoogleAdsNativeEventEmitter extends NativeEventEmitter {
// we will modify it to do our native unsubscription then call the original
let originalRemove = subscription.remove;
let newRemove = () => {
GoogleAdsModule.eventsRemoveListener(eventType, false);
RNGoogleAdsModule.eventsRemoveListener(eventType, false);
if (super.removeSubscription != null) {
// This is for RN <= 0.64 - 65 and greater no longer have removeSubscription
super.removeSubscription(subscription);
Expand All @@ -59,13 +59,13 @@ class GoogleAdsNativeEventEmitter extends NativeEventEmitter {
}

removeAllListeners(eventType) {
GoogleAdsModule.eventsRemoveListener(eventType, true);
RNGoogleAdsModule.eventsRemoveListener(eventType, true);
super.removeAllListeners(`google_ads_${eventType}`);
}

// This is likely no longer ever called, but it is here for backwards compatibility with RN <= 0.64
removeSubscription(subscription) {
GoogleAdsModule.eventsRemoveListener(subscription.eventType.replace('google_ads_'), false);
RNGoogleAdsModule.eventsRemoveListener(subscription.eventType.replace('google_ads_'), false);
if (super.removeSubscription) {
super.removeSubscription(subscription);
}
Expand Down

0 comments on commit 79f86b9

Please sign in to comment.