skrafft / react-native-jitsi-meet

React native wrapper for Jitsi Meet SDK
Apache License 2.0
285 stars 348 forks source link

background calling #182

Open deepakverma4 opened 4 years ago

deepakverma4 commented 4 years ago

the call keep connected if the user leaves the screen without ending current call but when user rejoins the meeting it crashes. how can we rejoin the meeting using jitsi sdk?

ricardodolnl commented 4 years ago

iOS uses callkit to show that a call is still active. But on android i'm using local notifications to show that a call is still active. It's a bit of a workaround because i think that the newest jitsi-meet-sdk version can make use of something called ConnectionService for android. What as far as i know works a bit the same as callkit from iOS.

But for now i send a local notification when the app goes to background while the user is in the jitsi-meet view. When the user opens the app again by clicking on the notification the app will remove the notification in the notification bar. Hope this helps you a bit.

componentDidMount() {
    AppState.addEventListener('change', this._handleAppStateChange);
  }

  componentWillUnmount() {
    AppState.removeEventListener('change', this._handleAppStateChange);
  }

_handleAppStateChange = nextAppState => {
    if (
      this.state.appState.match(/inactive|background/) &&
      nextAppState === 'active'
    ) {
      // App has come to the foreground!

      PushNotification.cancelAllLocalNotifications();
    } else {
      // App has gone to the background

      if (Platform.OS === 'android') {
        PushNotification.localNotification({
          ongoing: true,
          title: 'Ongoing meeting',
          message: 'You are currently in a meeting. Tap to return to it.',
        });
      }
    }
    this.setState({appState: nextAppState});
  };