UNPKG

expo-ads-admob

Version:

Provides support for the Google AdMob SDK (https://www.google.com/admob/) for mobile advertising. This module is largely based of the react-native-admob (https://github.com/sbugert/react-native-admob) module, as the documentation and questions surrounding

39 lines (34 loc) 1.23 kB
import { ConfigPlugin } from '@expo/config-plugins'; /** * Plugin to add [`SKAdNetworkIdentifier`](https://developer.apple.com/documentation/storekit/skadnetwork/configuring_the_participating_apps)s to the Info.plist safely. Always keep in sync with `expo-facebook`. * * @param config * @param props.identifiers array of lowercase string ids to push to the `SKAdNetworkItems` array in the `Info.plist`. */ export const withSKAdNetworkIdentifiers: ConfigPlugin<string[]> = (config, identifiers) => { if (!config.ios) { config.ios = {}; } if (!config.ios.infoPlist) { config.ios.infoPlist = {}; } if (!Array.isArray(config.ios.infoPlist.SKAdNetworkItems)) { config.ios.infoPlist.SKAdNetworkItems = []; } // Get ids let existingIds = config.ios.infoPlist.SKAdNetworkItems.map( (item: any) => item?.SKAdNetworkIdentifier ?? null ).filter(Boolean) as string[]; // remove duplicates existingIds = [...new Set(existingIds)]; for (const id of identifiers) { // Must be lowercase const lower = id.toLowerCase(); if (!existingIds.includes(lower)) { config.ios.infoPlist.SKAdNetworkItems.push({ SKAdNetworkIdentifier: lower, }); } } return config; };