[admob][android] Support multiple test devices
This commit is contained in:
parent
e52e01f735
commit
c710f135ce
|
@ -49,10 +49,6 @@ class RNFirebaseAdMobUtils {
|
|||
static AdRequest.Builder buildRequest(ReadableMap request) {
|
||||
AdRequest.Builder requestBuilder = new AdRequest.Builder();
|
||||
|
||||
if (request.hasKey("testDevice")) {
|
||||
requestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
|
||||
}
|
||||
|
||||
if (request.hasKey("isDesignedForFamilies")) {
|
||||
requestBuilder.setIsDesignedForFamilies(request.getBoolean("isDesignedForFamilies"));
|
||||
}
|
||||
|
@ -84,6 +80,19 @@ class RNFirebaseAdMobUtils {
|
|||
}
|
||||
}
|
||||
|
||||
// Handle testDevices array
|
||||
ReadableArray testDevices = request.getArray("keywords");
|
||||
List<Object> testDevicesList = Utils.recursivelyDeconstructReadableArray(testDevices);
|
||||
|
||||
for (Object deviceId : testDevicesList) {
|
||||
if (deviceId == "DEVICE_ID_EMULATOR") {
|
||||
requestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
|
||||
} else {
|
||||
requestBuilder.addTestDevice((String) deviceId);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle keywords array
|
||||
ReadableArray keywords = request.getArray("keywords");
|
||||
List<Object> keywordsList = Utils.recursivelyDeconstructReadableArray(keywords);
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ export default class AdRequest {
|
|||
constructor() {
|
||||
this._props = {
|
||||
keywords: [],
|
||||
testDevices: [],
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -10,8 +11,8 @@ export default class AdRequest {
|
|||
return this._props;
|
||||
}
|
||||
|
||||
addTestDevice() {
|
||||
this._props.testDevice = true;
|
||||
addTestDevice(deviceId?: string) {
|
||||
this._props.testDevices.push(deviceId ? deviceId : 'DEVICE_ID_EMULATOR');
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ export default function addTests({ before, fdescribe, describe, it, firebase })
|
|||
const build = request.build();
|
||||
|
||||
build.should.have.property('keywords').and.be.a.Array();
|
||||
build.should.have.property('testDevices').and.be.a.Array();
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
@ -65,6 +66,7 @@ export default function addTests({ before, fdescribe, describe, it, firebase })
|
|||
|
||||
request
|
||||
.addTestDevice()
|
||||
.addTestDevice('foobar')
|
||||
.addKeyword('foo')
|
||||
.addKeyword('bar')
|
||||
// .setBirthday() // TODO
|
||||
|
@ -78,8 +80,10 @@ export default function addTests({ before, fdescribe, describe, it, firebase })
|
|||
const build = request.build();
|
||||
|
||||
build.should.have.property('keywords').and.be.a.Array();
|
||||
build.should.have.property('testDevices').and.be.a.Array();
|
||||
build.keywords.should.containEql('foo');
|
||||
build.keywords.should.containEql('bar');
|
||||
build.testDevices.should.containEql('foobar');
|
||||
build.should.have.property('contentUrl').and.be.a.equal('http://google.com');
|
||||
build.should.have.property('gender').and.be.a.equal('female');
|
||||
build.should.have.property('requestAgent').and.be.a.equal('foobar');
|
||||
|
|
Loading…
Reference in New Issue