Basic usage of @react-native-firebase/admob gives: quot;TypeError: (0, _admob.default) is not a functionquot;. Is it deprecated? or Why doesnt work?(@react-native-firebase/admob 的基本用法给出:“TypeError: (0, _admob.default) is not a function.是否已弃用?或为什么不起作用?) -
问题描述
@react-native-firebase/admob 是否已弃用?或者只是......为什么它不起作用?
Is @react-native-firebase/admob deprecated? or just.. Why it doesn't work?
我正在使用 @react-native-firebase/admob (https://rnfb-docs.netlify.app/admob/usage).在使用admob()"之前一切正常.当我将 admob() 添加到代码时出现此错误:
I am using @react-native-firebase/admob (https://rnfb-docs.netlify.app/admob/usage). Everything works fine before to use "admob()". When I add admob() to the code appears this error:
TypeError: (0, _admob.default) 不是函数"
"TypeError: (0, _admob.default) is not a function"
有人知道为什么吗?
我的代码如下(基本用法):
My code below (basic usage):
import React from 'react';
import { Text, View} from 'react-native';
import admob, { MaxAdContentRating } from '@react-native-firebase/admob';
import { InterstitialAd, RewardedAd, BannerAd, TestIds } from '@react-native-
firebase/admob';
import { BannerAdSize} from '@react-native-firebase/admob';
class App extends React.Component{
componentDidMount(){
// this was taked of official page: https://rnfb-docs.netlify.app/admob/usage#installation
admob()
.setRequestConfiguration({
// Update all future requests suitable for parental guidance
maxAdContentRating: MaxAdContentRating.PG,
// Indicates that you want your content treated as child-directed for purposes of COPPA.
tagForChildDirectedTreatment: true,
// Indicates that you want the ad request to be handled in a
// manner suitable for users under the age of consent.
tagForUnderAgeOfConsent: true,
})
.then(() => {
// Request config successfully set!
});
}
render(){
return(
<View style={{
alignItems:"center",
justifyContent:"center",
height:"100%"}}>
<Text style={{color:"black"}}>
Hola
</Text>
<BannerAd
unitId={TestIds.BANNER}
size={BannerAdSize.FULL_BANNER} />
</View>
)
}
}
export default App;
推荐答案
我能解决.
已解决
只需签入文件package.json"即可firebase 的软件包具有相同的版本,例如:
Just check in the file "package.json" that packages of firebase has the same version, example:
dependencies{
"@react-native-firebase/admob": "^11.5.0",
"@react-native-firebase/app": "^11.5.0"
}
提示
适用于类似错误.
这篇关于@react-native-firebase/admob 的基本用法给出:“TypeError: (0, _admob.default) is not a function".是否已弃用?或为什么不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:@react-native-firebase/admob 的基本用法给出:“TypeError: (0, _admob.default) is not a function".是否已弃用?或为什么不起作用?
基础教程推荐
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01