2
0
mirror of synced 2025-02-12 22:36:43 +00:00

[ios][admob] Fix testDevices not adding emulator device

This commit is contained in:
Elliot Hesp 2017-06-16 15:21:49 +01:00
parent af5bf655fe
commit f6db5656ae

View File

@ -79,14 +79,28 @@ RCT_EXPORT_METHOD(rewardedVideoShowAd:
return @[ADMOB_INTERSTITIAL_EVENT, ADMOB_REWARDED_VIDEO_EVENT]; return @[ADMOB_INTERSTITIAL_EVENT, ADMOB_REWARDED_VIDEO_EVENT];
} }
- (GADRequest *)buildRequest:(NSDictionary *)request { + (GADRequest *)buildRequest:(NSDictionary *)request {
GADRequest *builder = [GADRequest request]; GADRequest *builder = [GADRequest request];
if (request[@"tagForChildDirectedTreatment"]) [builder tagForChildDirectedTreatment:(BOOL) request[@"tagForChildDirectedTreatment"]]; if (request[@"tagForChildDirectedTreatment"]) [builder tagForChildDirectedTreatment:(BOOL) request[@"tagForChildDirectedTreatment"]];
if (request[@"contentUrl"]) builder.contentURL = request[@"contentUrl"]; if (request[@"contentUrl"]) builder.contentURL = request[@"contentUrl"];
if (request[@"requestAgent"]) builder.requestAgent = request[@"requestAgent"]; if (request[@"requestAgent"]) builder.requestAgent = request[@"requestAgent"];
if (request[@"keywords"]) builder.keywords = request[@"keywords"]; if (request[@"keywords"]) builder.keywords = request[@"keywords"];
if (request[@"testDevices"]) builder.testDevices = request[@"testDevices"];
if (request[@"testDevices"]) {
NSArray * devices = request[@"testDevices"];
NSMutableArray * testDevices = [[NSMutableArray alloc] init];
for (id device in devices) {
if ([device isEqual:@"DEVICE_ID_EMULATOR"]) {
[testDevices addObject:kGADSimulatorID];
} else {
[testDevices addObject:device];
}
}
builder.testDevices = testDevices;
}
if (request[@"gender"]) { if (request[@"gender"]) {
NSString *gender = [request[@"gender"] stringValue]; NSString *gender = [request[@"gender"] stringValue];
@ -103,7 +117,7 @@ RCT_EXPORT_METHOD(rewardedVideoShowAd:
return builder; return builder;
} }
- (NSDictionary *)errorCodeToDictionary:(NSError *)error { + (NSDictionary *)errorCodeToDictionary:(NSError *)error {
NSString *code; NSString *code;
NSString *message; NSString *message;
@ -147,4 +161,22 @@ RCT_EXPORT_METHOD(rewardedVideoShowAd:
}; };
} }
+ (GADAdSize)stringToAdSize:(NSString *)value {
if ([value isEqualToString:@"BANNER"]) {
return kGADAdSizeBanner;
} else if ([value isEqualToString:@"LARGE_BANNER"]) {
return kGADAdSizeLargeBanner;
} else if ([value isEqualToString:@"MEDIUM_RECTANGLE"]) {
return kGADAdSizeMediumRectangle;
} else if ([value isEqualToString:@"FULL_BANNER"]) {
return kGADAdSizeFullBanner;
} else if ([value isEqualToString:@"LEADERBOARD"]) {
return kGADAdSizeLeaderboard;
} else if ([value isEqualToString:@"SMART_BANNER"]) {
return kGADAdSizeSmartBannerPortrait;
} else {
return kGADAdSizeBanner;
}
}
@end @end