我正在使用https://docs.expo.io/versions/latest/sdk/facebook-ads在我的应用程序中添加Facebook广告。我完全按照文档操作,但在我的应用程序主屏幕上看不到Facebook广告。
BottomBannerAd.js
import React from 'react';
import { FacebookAds } from 'expo';
const { AdIconView, AdMediaView } = FacebookAds;
class AdComponent extends React.Component {
render() {
return (
<View>
<AdMediaView />
<AdTriggerView>
<Text>{this.props.nativeAd.bodyText}</Text>
</AdTriggerView>
</View>
);
}
}
export default FacebookAds.withNativeAd(AdComponent);HomeScreen.js
import React from 'react';
import { Image, TextInput, FlatList, StyleSheet, Text, View,
TouchableOpacity, ActivityIndicator, Platform } from 'react-native';
import { NavigationEvents } from 'react-navigation';
import { FacebookAds } from 'expo';
import AdComponent from '../components/BottomBannerAd';
const adsManager = new FacebookAds.NativeAdsManager('xxxxxxxxxxx', 10);
import {
AdMobBanner,
AdMobInterstitial,
AdMobRewarded
} from "expo";
export default class HomeScreen extends React.Component {
render(){
return (
<View style={styles.container}>
...
<View style={styles.tabBarInfoContainer}>
<AdComponent adsManager={adsManager} />
</View>
</View>
)
}
}我有一个包含广告组件的视图组件。当我添加Google广告时,这个视图组件工作得很好,但不适用于Facebook广告。
发布于 2019-04-23 21:39:37
一种解决方案是输入一个实际的设备ID进行测试,否则我无法让它工作。

上面的代码应该会生成类似这样的内容(附件如下),但只在活动设备上生成。

通常的测试方法应该是在代码中添加一个FacebookAds.AdSettings.addTestDevice(FacebookAds.AdSettings.currentDeviceHash);,但它不起作用(至少对我来说是这样)。
要在iPhone上获取IDFA,请从AppStore下载DeviceId (通过AppsFlyer),并在您的隐私>广告设置中禁用限制广告跟踪。
希望能有所帮助。
发布于 2019-03-08 11:26:22
看看这个- react-native with expo problem with facebook ads
我也有同样的问题。FB广告似乎在当前的世博会建设中被打破了。
https://stackoverflow.com/questions/54004943
复制相似问题