如何使用React Native脚本在后台接收Firebase通知

时间:2018-10-01 15:47:18

标签: javascript firebase react-native firebase-cloud-messaging react-native-firebase

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();
   }

请帮助我找到上述代码中的问题。还有其他解决方案可以在后台运行该应用程序,并在收到通知时完成所需的任务。

0 个答案:

没有答案