diff --git a/bgMessaging.js b/bgMessaging.js index 0986a72..24bd4d8 100644 --- a/bgMessaging.js +++ b/bgMessaging.js @@ -1,21 +1,23 @@ //@flow import { NativeModules, AppState } from 'react-native'; -import Logger from './Logger'; const { SylkNative } = NativeModules; -const logger = new Logger('bgMessaging'); +//import { AppState } from 'react-native'; +//import SajjadLaunchApplication from 'react-native-launch-application'; export default async (remoteMessage) => { - logger.debug("Data notification received in state " + AppState.currentState, remoteMessage, SylkNative); + console.log("Data notification received in state " + AppState.currentState, remoteMessage, SylkNative); - if( - AppState.currentState == "background" && + if (AppState.currentState == "background" && (remoteMessage.data.event === 'incoming_session' || remoteMessage.data.event === 'incoming_conference_request') ) { //rnn_hasRNHost indicates if the app has a react native host when the notification was received. This is used to determine if the app was in the background or dead. If it was dead then launch the main activity to wake enough of the phone to be useful. console.log('Wake up from push'); SylkNative.launchMainActivity(); + + //https://github.com/lvlrSajjad/react-native-launch-application + //SajjadLaunchApplication.open("com.agprojects.sylk"); } return Promise.resolve(); -} \ No newline at end of file +} diff --git a/index.js b/index.js index e0a8f14..a78998e 100644 --- a/index.js +++ b/index.js @@ -1,20 +1,21 @@ /** * @format */ import { AppRegistry } from 'react-native'; import App from './app/app'; import { name as appName } from './app.json'; import bgMessaging from './bgMessaging'; import bgCalling from './bgCalling'; import { firebase } from '@react-native-firebase/messaging'; console.disableYellowBox = true; // New background task registration firebase.messaging().setBackgroundMessageHandler(bgMessaging); AppRegistry.registerComponent(appName, () => App); AppRegistry.registerHeadlessTask('RNCallKeepBackgroundMessage', () => bgCalling); +AppRegistry.registerHeadlessTask('RNFirebaseBackgroundMessage', () => bgMessaging);