react-native-admob-native-ads icon indicating copy to clipboard operation
react-native-admob-native-ads copied to clipboard

Custom targeting not working on iOS

Open mwh1r opened this issue 3 years ago • 0 comments

Firstly, nice library 👏

I have custom targeting setup for ads and it works on Android but not iOS.

Docs define type for targets as array of Target:{ key: boolean, value: string | Array<string> } so have something like the following:

<NativeAdView
    ref={ref}
    targetingOptions={{
      targets: [
        { key: 'key1', value: 'value1' },
        { key: 'key2', value: 'value2' },
      ],
    }}
    adUnitID={adUnitID}>
    ...
</NativeAdView>

Looking at the native code, i can see the Android code seems to handle the targets prop based on the type - but the iOS code does not seem to do the same sort of logic.

So taking that into account, i changed targets to something like the following and sure enough it worked on iOS:

<NativeAdView
   ref={ref}
   targetingOptions={{
     targets:
       Platform.OS === 'android'
         ? [
             { key: 'key1', value: 'value1' },
             { key: 'key2', value: 'value2' },
           ]
         : { key1: 'value1', key2: 'value2' },
   }}
   adUnitID={adUnitID}>
   ...
</NativeAdView>

Am i missing something here or is this indeed an issue?

mwh1r avatar Sep 20 '22 22:09 mwh1r