Facebook广告不适用于SDK 33世博会

时间:2019-07-09 11:36:31

标签: react-native expo facebook-ads-api

我已将Expo sdk升级到最新版本(33.0.0)。我已经更改了所有需要的内容(更改了fb广告的导入方式,如下所示:

import * as FacebookAds from 'expo-ads-facebook';并下载)。

两天前(当时我在sdk 32上)运行此应用程序时一切正常,但现在... 我读到我需要更改的所有内容,因此fb ads工作只是导入和下载。当我运行我的应用程序时,fb广告没有显示,并且在控制台中显示此错误:

error SyntheticEvent {
  "_dispatchInstances": FiberNode {
    "tag": 5,
    "key": null,
    "type": "ViewManagerAdapter_CTKBannerView",
  },
  "_dispatchListeners": [Function onError],
  "_targetInst": FiberNode {
    "tag": 5,
    "key": null,
    "type": "ViewManagerAdapter_CTKBannerView",
  },
  "bubbles": undefined,
  "cancelable": undefined,
  "currentTarget": 1255,
  "defaultPrevented": undefined,
  "dispatchConfig": Object {
    "registrationName": "onAdError",
  },
  "eventPhase": undefined,
  "isDefaultPrevented": [Function functionThatReturnsFalse],
  "isPropagationStopped": [Function functionThatReturnsFalse],
  "isTrusted": undefined,
  "nativeEvent": Object {
    "errorCode": 1002,
    "errorMessage": "Ad was re-loaded too frequently",
  },
  "target": undefined,
  "timeStamp": 1562671873682,
  "type": undefined,
}

我在做什么错? 代码:

// page.js
import React from 'react';

import { View } from 'react-native';
import { createStackNavigator, createAppContainer } from 'react-navigation'; // Version can be specified in package.json
import * as FacebookAds from 'expo-ads-facebook';

import AdScreenFacebook from './AdScreenFacebook'

const adsManager = new FacebookAds.NativeAdsManager("2272791379702600_2272795453035526", 10);

class AdScreen extends React.Component {
  render () {
          return (
  <View>
  <AdScreenFacebook adsManager={adsManager} />

  <FacebookAds.BannerAd
      placementId="2272791379702600_2272803043034767"
      type="standard"
      onPress={() => console.log('click')}
      onError={error => console.log('error', error)}
    />
    </View>
          );
      }

 }


  export default createStackNavigator(
    {
      Main: {
        screen: AdScreen,
      },
      AdScreenFacebook: {
        screen: AdScreenFacebook,
      }
    },
    {
      initialRouteName: 'Main',
    }
  );
  
  // AdScreenFacebook.js
  
  import React from 'react';

import { StyleSheet, Text, View, Dimensions } from 'react-native';

import * as FacebookAds from 'expo-ads-facebook';
const { AdTriggerView, AdMediaView, AdIconView } = FacebookAds;


class AdScreenFacebook extends React.Component {
  render () {
          return (
            <View style={{  flexDirection: 'column',
    justifyContent: 'center',
    alignItems: 'center',}}>
            <View style={{ width:500}}>
                   <AdMediaView style={{ width: 160, height: 90 }}/>
                   <View style={{flexDirection: 'row'}}>
                   <AdIconView style={{ width: 50, height: 50 }}/>
                   <AdTriggerView>
                     <Text>{this.props.nativeAd.bodyText}</Text>
                       <Text>{this.props.nativeAd.callToActionText}</Text>
                   </AdTriggerView>
                 </View>
                  </View>
                    </View>
    );
      }

 }


export default FacebookAds.withNativeAd(AdScreenFacebook);

1 个答案:

答案 0 :(得分:0)

升级FB SDK现在open issue

目前,已确认在没有分开的条件下未实施Expo构建,从而导致错误。

如果您想立即使用它,请运行expo eject (使用Expokit)