index.js:
import bgNotification from './bgNotification'
AppRegistry.registerHeadlessTask('RNFirebaseBackgroundMessage', () =>
bgNotification);
build.gradle:
implementation project(':react-native-firebase')
implementation "com.google.android.gms:play-services-base:15.0.1"
implementation "com.google.firebase:firebase-core:15.0.2"
implementation "com.google.firebase:firebase-storage:15.0.2"
implementation "com.google.firebase:firebase-messaging:15.0.2"
implementation "com.google.firebase:firebase-auth:15.0.0"
bgNotification.js:
import firebase from 'react-native-firebase';
// Optional flow type
import type { RemoteMessage } from 'react-native-firebase';
export default async (message: RemoteMessage) => {
return Promise.resolve();
}
请帮助我找到上述代码中的问题。还有其他解决方案可以在后台运行该应用程序,并在收到通知时完成所需的任务。