使用React Native Firebase Cloud Messaging时遭遇弃用警告的问题咨询
使用React Native Firebase Cloud Messaging时遭遇弃用警告的问题咨询
我最近新建了一个React Native项目,正在使用React Native Firebase的Cloud Messaging功能,完全是照着官方文档里的示例代码来写的,但在Chrome DevTools里弹出了一条弃用警告。
警告内容如下:
index.js:38 This method is deprecated (as well as all React Native Firebase namespaced API) and will be removed in the next major release as part of move to match Firebase Web modular SDK API. Please see migration guide for more details. Please use
getApp()instead.
警告截图:
以下是我目前的代码:
index.js
import {AppRegistry} from 'react-native'; import App from './App'; import {name as appName} from './app.json'; import messaging from '@react-native-firebase/messaging'; AppRegistry.registerComponent(appName, () => App); messaging() .onMessage(async notification => { /* Code goes here */ }); messaging() .setBackgroundMessageHandler(async remoteMessage => { /* Code goes here */ });
想请教一下,现在正确的用法应该是什么?为什么官方文档还在展示旧版本的使用示例呢?
备注:内容来源于stack exchange,提问作者Hasan ABLAK
相关产品推荐
相关产品推荐

