Mau*_*ias 5 android admob google-play-services react-native react-native-firebase
@react-native-firebase/admob 是否已弃用?或者只是......为什么它不起作用?
我正在使用@react-native-firebase/admob(https://rnfb-docs.netlify.app/admob/usage)。在使用“admob()”之前一切正常。当我将 admob() 添加到代码中时出现此错误:
“类型错误:(0,_admob.default)不是函数”
有人知道为什么吗?
我的代码如下(基本用法):
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;
Run Code Online (Sandbox Code Playgroud)
Fed*_*Baù 10
尽管有 @CodeJoe 的回答,我仍然对周围的 React Native Firebase 的不同文档感到困惑,因此我花了很多时间和精力来解决它。
我在这里提出了一个问题,确认 Google 自 以来删除了 AdMob 软件包v11.5.0。
AdMob 不再包含在 Firebase API 中,因此该模块不再包装它,也没有需要更正的文档。然而,它确实在 v11.5.0 版本中存在,如果您当时浏览存储库,您可能会考虑当时对 AdMob 的 e2e 测试作为“如何使用 AdMob”的入门读本https://github.com/invertase /react-native-firebase/tree/0217bff5cbbf233d7915efb4dbbdfe00e82dff23/packages/admob/e2e
请不要像我一样检查正确的文档和网站:
互联网有很长的记忆力,所以有一些过时的文档副本,但是 rnfirebase.io 始终是官方和当前的文档站点
Admob 已被 Google 从 Firebase 生态系统中完全删除,因此这里不存在 Admob。有一些社区包,我们的 v11.5 版本就有它,我们希望剥离我们的实现并为社区更新它,但这需要时间,不幸的是我们仍然积压官方 firebase api,所以它还没有还发生过
因此,对于 AdMob 解决方案,我将使用另一个库,并使用react-native-firebase作为他们当前提供的解决方案
免责声明
我可以解决它。
解决了
只需检查文件“package.json”中 firebase 的包是否具有相同的版本,例如:
dependencies{
"@react-native-firebase/admob": "^11.5.0",
"@react-native-firebase/app": "^11.5.0"
}
Run Code Online (Sandbox Code Playgroud)
提示
适用于类似的错误。
| 归档时间: |
|
| 查看次数: |
3333 次 |
| 最近记录: |