Skip to content

Commit

Permalink
refactor: set testdevices for all ads, instead of per request
Browse files Browse the repository at this point in the history
  • Loading branch information
dylancom authored and mikehardy committed Dec 10, 2021
1 parent 4be5993 commit d8c0c38
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
12 changes: 0 additions & 12 deletions ios/RNGoogleAds/RNGoogleAdsCommon.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,6 @@ + (GADRequest *)buildAdRequest:(NSDictionary *)adRequestOptions {
request.keywords = adRequestOptions[@"keywords"];
}

// if (adRequestOptions[@"testDevices"]) {
// NSMutableArray *devices = [@[] mutableCopy];
// for (NSString *key in adRequestOptions[@"testDevices"]) {
// if ([key isEqualToString:@"EMULATOR"]) {
// [devices addObject:GADSimulatorID];
// } else {
// [devices addObject:key];
// }
// }
// request.testDevices = devices;
// }

if (adRequestOptions[@"location"]) {
NSArray<NSNumber *> *latLong = adRequestOptions[@"location"];
[request setLocationWithLatitude:[latLong[0] doubleValue]
Expand Down
12 changes: 12 additions & 0 deletions ios/RNGoogleAds/RNGoogleAdsModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ - (void)setRequestConfiguration:(NSDictionary *)requestConfiguration {
BOOL tag = (BOOL)requestConfiguration[@"tagForUnderAgeOfConsent"];
[GADMobileAds.sharedInstance.requestConfiguration tagForUnderAgeOfConsent:tag];
}

if (requestConfiguration[@"testDeviceIdentifiers"]) {
NSMutableArray *devices = [@[] mutableCopy];
for (NSString *key in requestConfiguration[@"testDeviceIdentifiers"]) {
if ([key isEqualToString:@"EMULATOR"]) {
[devices addObject:GADSimulatorID];
} else {
[devices addObject:key];
}
}
GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers = devices;
}
}

@end
20 changes: 7 additions & 13 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -669,19 +669,6 @@ export namespace GoogleAdsTypes {
*/
keywords?: string[];

/**
* An array of test device IDs to whitelist.
*
* If using an emulator, set the device ID to `EMULATOR`.
*
* ```js
* await Interstitial.request('ca-app-pub-3940256099942544/1033173712', {
* testDevices: ['EMULATOR'],
* });
* ```
*/
testDevices?: string[];

/**
* Sets a content URL for targeting purposes.
*
Expand Down Expand Up @@ -784,6 +771,13 @@ export namespace GoogleAdsTypes {
* See the [Google Mobile SDK docs](https://developers.google.com/admob/android/targeting#ad_content_filtering) for more information.
*/
tagForUnderAgeOfConsent?: boolean;

/**
* An array of test device IDs to whitelist.
*
* If using an emulator, set the device ID to `EMULATOR`.
*/
testDeviceIdentifiers?: string[];
}

/**
Expand Down

0 comments on commit d8c0c38

Please sign in to comment.