【问题标题】:How to setup Facebook ads using Expo?如何使用 Expo 设置 Facebook 广告?
【发布时间】:2019-01-02 10:46:39
【问题描述】:

我正在使用 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 广告。

【问题讨论】:

    标签: reactjs facebook react-native expo


    【解决方案1】:

    一种解决方案是输入一个实际的设备 ID 进行测试,否则我无法让它工作。

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

    正常的测试方式应该是添加一个 FacebookAds.AdSettings.addTestDevice(FacebookAds.AdSettings.currentDeviceHash); 到您的代码中,但它不起作用(至少对我而言)。

    要在 iPhone 上获取 IDFA id,请从 AppStore 下载 DeviceId(由 AppsFlyer),并在您的隐私 > 广告设置中禁用限制广告跟踪。

    希望对你有帮助。

    【讨论】:

    • 在哪里可以找到“currentDeviceHash”的代码?我想尝试使用真正的 Android 应用代码。
    【解决方案2】:

    看看这个 - react-native with expo problem with facebook ads

    我也有同样的问题。看来 FB 广告在当前的世博会版本中被破坏了。

    【讨论】:

      猜你喜欢
      • 2017-07-30
      • 1970-01-01
      • 2020-03-09
      • 2016-08-17
      • 1970-01-01
      • 1970-01-01
      • 2014-06-22
      • 1970-01-01
      • 2014-05-26
      相关资源
      最近更新 更多