Skip to content

Commit

Permalink
feat: add ppid option to request options (#153)
Browse files Browse the repository at this point in the history
* feat: add ppid option to request options
* fix: run lint fixes
  • Loading branch information
wjaykim authored May 30, 2022
1 parent 9ee2527 commit 8bbfc05
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ public static AdManagerAdRequest buildAdRequest(ReadableMap adRequestOptions) {
}
}

if (adRequestOptions.hasKey("publisherProvidedId")) {
builder.setPublisherProvidedId(
Objects.requireNonNull(adRequestOptions.getString("publisherProvidedId")));
}

return builder.build();
}

Expand Down
4 changes: 4 additions & 0 deletions ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ + (GAMRequest *)buildAdRequest:(NSDictionary *)adRequestOptions {
request.customTargeting = adRequestOptions[@"customTargeting"];
}

if (adRequestOptions[@"publisherProvidedId"]) {
request.publisherProvidedID = adRequestOptions[@"publisherProvidedId"];
}

return request;
}

Expand Down
7 changes: 7 additions & 0 deletions src/types/RequestOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,11 @@ export interface RequestOptions {
* See [Google Mobile SDK Docs](https://developers.google.com/admob/android/ssv) for more information.
*/
serverSideVerificationOptions?: ServerSideVerificationOptions;

/**
* Publisher provided identifier (PPID) for use in frequency capping, audience segmentation and targeting,
* sequential ad rotation, and other audience-based ad delivery controls across devices.
* See [this article](https://support.google.com/admanager/answer/2880055) for more information.
*/
publisherProvidedId?: string;
}
7 changes: 7 additions & 0 deletions src/validateAdRequestOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,12 @@ export function validateAdRequestOptions(options?: RequestOptions) {
out.customTargeting = options.customTargeting;
}

if (options.publisherProvidedId) {
if (!isString(options.publisherProvidedId)) {
throw new Error("'options.publisherProvidedId' expected a string value");
}
out.publisherProvidedId = options.publisherProvidedId;
}

return out;
}

0 comments on commit 8bbfc05

Please sign in to comment.