diff --git a/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java b/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java index 8fb352bf..f874ba82 100644 --- a/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java +++ b/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java @@ -183,6 +183,11 @@ public static AdManagerAdRequest buildAdRequest(ReadableMap adRequestOptions) { } } + if (adRequestOptions.hasKey("publisherProvidedId")) { + builder.setPublisherProvidedId( + Objects.requireNonNull(adRequestOptions.getString("publisherProvidedId"))); + } + return builder.build(); } diff --git a/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m b/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m index f3d149e3..dd707ac6 100644 --- a/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m +++ b/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m @@ -83,6 +83,10 @@ + (GAMRequest *)buildAdRequest:(NSDictionary *)adRequestOptions { request.customTargeting = adRequestOptions[@"customTargeting"]; } + if (adRequestOptions[@"publisherProvidedId"]) { + request.publisherProvidedID = adRequestOptions[@"publisherProvidedId"]; + } + return request; } diff --git a/src/types/RequestOptions.ts b/src/types/RequestOptions.ts index 780350cb..ef6fdbdb 100644 --- a/src/types/RequestOptions.ts +++ b/src/types/RequestOptions.ts @@ -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; } diff --git a/src/validateAdRequestOptions.ts b/src/validateAdRequestOptions.ts index 74f1c183..5d7435f9 100644 --- a/src/validateAdRequestOptions.ts +++ b/src/validateAdRequestOptions.ts @@ -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; }