From 658f4d7eabca3d0745d19e5c916aee56066bdbf9 Mon Sep 17 00:00:00 2001 From: GleidsonDaniel Date: Thu, 20 Apr 2023 10:35:06 -0300 Subject: [PATCH] add option to open jitsi app --- android/app/src/main/AndroidManifest.xml | 6 ----- app/views/JitsiMeetView.tsx | 33 ++++++++++-------------- package.json | 1 - yarn.lock | 5 ---- 4 files changed, 14 insertions(+), 31 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index e5c7b75dc..b1305bfd6 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -79,10 +79,4 @@ - - - - - - diff --git a/app/views/JitsiMeetView.tsx b/app/views/JitsiMeetView.tsx index a5098efc3..fcaa9a75e 100644 --- a/app/views/JitsiMeetView.tsx +++ b/app/views/JitsiMeetView.tsx @@ -1,20 +1,16 @@ import { activateKeepAwake, deactivateKeepAwake } from 'expo-keep-awake'; import React from 'react'; -import { BackHandler, NativeEventSubscription, SafeAreaView } from 'react-native'; -import { isAppInstalled, openAppWithUri } from 'react-native-send-intent'; +import { BackHandler, Linking, NativeEventSubscription, SafeAreaView } from 'react-native'; import WebView from 'react-native-webview'; import { WebViewMessage, WebViewNavigation } from 'react-native-webview/lib/WebViewTypes'; import { IBaseScreen } from '../definitions'; import { userAgent } from '../lib/constants'; -import { isAndroid } from '../lib/methods/helpers'; import { events, logEvent } from '../lib/methods/helpers/log'; import { endVideoConfTimer, initVideoConfTimer } from '../lib/methods/videoConfTimer'; import { ChatsStackParamList } from '../stacks/types'; import { withTheme } from '../theme'; -const JITSI_INTENT = 'org.jitsi.meet'; - type TJitsiMeetViewProps = IBaseScreen; class JitsiMeetView extends React.Component { @@ -31,20 +27,7 @@ class JitsiMeetView extends React.Component { } componentDidMount() { - const { route, navigation } = this.props; - if (isAndroid) { - isAppInstalled(JITSI_INTENT) - .then(function (isInstalled) { - if (isInstalled) { - const callUrl = route.params.url.replace(/^https?:\/\//, '').split('#')[0]; - openAppWithUri(`intent://${callUrl}#Intent;scheme=${JITSI_INTENT};package=${JITSI_INTENT};end`) - .then(() => navigation.pop()) - .catch(() => {}); - } - }) - .catch(() => {}); - this.backHandler = BackHandler.addEventListener('hardwareBackPress', () => true); - } + this.handleJitsiApp(); this.onConferenceJoined(); activateKeepAwake(); } @@ -60,6 +43,18 @@ class JitsiMeetView extends React.Component { deactivateKeepAwake(); } + handleJitsiApp = async () => { + const { route, navigation } = this.props; + const callUrl = route.params.url.replace(/^https?:\/\//, ''); + try { + await Linking.openURL(`org.jitsi.meet://${callUrl}`); + navigation.pop(); + } catch (error) { + // As the jitsi app was not opened disable the backhandler on android + this.backHandler = BackHandler.addEventListener('hardwareBackPress', () => true); + } + }; + // Jitsi Update Timeout needs to be called every 10 seconds to make sure // call is not ended and is available to web users. onConferenceJoined = () => { diff --git a/package.json b/package.json index cc6587318..23d49b56e 100644 --- a/package.json +++ b/package.json @@ -126,7 +126,6 @@ "react-native-safe-area-context": "3.2.0", "react-native-screens": "3.13.1", "react-native-scrollable-tab-view": "ptomasroos/react-native-scrollable-tab-view", - "react-native-send-intent": "^1.3.0", "react-native-simple-crypto": "RocketChat/react-native-simple-crypto#0.5.1", "react-native-skeleton-placeholder": "^5.2.3", "react-native-slowlog": "^1.0.2", diff --git a/yarn.lock b/yarn.lock index 9dea4782e..228407791 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17577,11 +17577,6 @@ react-native-scrollable-tab-view@ptomasroos/react-native-scrollable-tab-view: prop-types "^15.6.0" react-timer-mixin "^0.13.3" -react-native-send-intent@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/react-native-send-intent/-/react-native-send-intent-1.3.0.tgz#d8c7898827da1b8b10e25a645ce6802d1a0b440c" - integrity sha512-ODTX7BHITFxdcAL0K2iHfa3qVYnqG8GPcv1NbLBNC1DyCaOSJiiGtVH6Kc5YBqzQ8+1pV9uN5nfQ5wyFgiq74g== - react-native-simple-crypto@RocketChat/react-native-simple-crypto#0.5.1: version "0.5.1" resolved "https://codeload.github.com/RocketChat/react-native-simple-crypto/tar.gz/dcf6eef5359c739d521371918e13a73f2ea6cb42"