react-native Firebase我使用和创建了推送通知react-native-push-notification。我已经实现了所有类型的通知,例如本地通知、计划背景通知和退出通知。但当我的应用程序处于退出状态时,我已通过FCM发送了推送通知。所以我在控制台上显示了一条警告,即WARN No task Registration for key ReactNativeFirebaseMessagingHeadlessTask。那我该如何解决呢。
代码:
import React, {Fragment, useEffect} from 'react';
import {StyleSheet, View, Text, Button} from 'react-native';
import PushNotification from 'react-native-push-notification';
import messaging from '@react-native-firebase/messaging';
//1
const checkPermission = () => {
messaging()
.hasPermission()
.then((enabled) => {
if (enabled) {
getToken();
} else {
requestPermission();
}
})
.catch((error) => {
console.log('error checking permisions ' + error);
});
};
//2
const requestPermission = () => {
messaging()
.requestPermission()
.then(() …Run Code Online (Sandbox Code Playgroud) react-native firebase-cloud-messaging react-native-firebase react-native-push-notification