react-native-inappbrowser for Android

377 Views Asked by At

I have an app in ReactNative that uses a webview to load a url and I'm trying to open the url inside that url with inappbrowser-reborn but when I run the project with npm run android on a real device I get this error. inappbrowser-reborn does not expire and closes I am new to this issue please find me a way to fix it This is the Index.js code snippet from where I'm trying to open inappbrowser

     onShouldStartLoadWithRequest={(event) => {
       const { url } = event;
       if (!url.startsWith('https://portal.bsu')) {
         console.log('Blocked navigation to URL:', url);
         //navigation.navigate('NewTab', { redirectedUrl: url });
          // Open the redirected URL in the InAppBrowser without using 'await'
          InAppBrowser.open(url, {
           // Customize your InAppBrowser options here
            toolbarColor: '#03a9f3',
            readerMode: false,
            animated: true,
            modalPresentationStyle: 'overFullScreen',
            modalTransitionStyle: 'coverVertical',
            modalEnabled: true,
            enableBarCollapsing: false,
            // Android Properties
            showTitle: true,
            enableUrlBarHiding: true,
            enableDefaultShare: false,
            forceCloseOnRedirection: false,
            // iOS-specific option to open in the WebView
            usewkwebview: true, // Add this line to open in WebView on iOS
           
       })
         .then((result) => {
           
           // Add a log after opening InAppBrowser
           console.log('InAppBrowser opened successfully:', result);
         })
         .catch((error) => {
           // Add a log for any errors
           console.error('Error opening InAppBrowser:', error.message);
         });
         return false; // Block navigation for URLs that do not start with 'https://portal.bsu'
       }

But the application closes and I get this error in the android studio logs

2023-10-14 14:49:37.201  6638-16422 ReactNativeJS           com.bsuportal                        I  'Blocked navigation to URL:', 'http://spm.bsu.edu.ge/services/auth/login/?token=7f282434acdb93ee67deef11a9781521'
2023-10-14 14:49:37.231  6638-16423 AndroidRuntime          com.bsuportal                        E  FATAL EXCEPTION: mqt_native_modules
                                                                                                    Process: com.bsuportal, PID: 6638
                                                                                                    x6.e: Subscriber class h5.c and its super classes have no public methods with the @Subscribe annotation
                                                                                                        at x6.p.a(Unknown Source:58)
                                                                                                        at x6.c.p(Unknown Source:6)
                                                                                                        at h5.c.l(Unknown Source:14)
                                                                                                        at h5.c.k(Unknown Source:352)
                                                                                                        at com.proyecto26.inappbrowser.RNInAppBrowserModule.open(Unknown Source:10)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.facebook.react.bridge.JavaMethodWrapper.invoke(Unknown Source:148)
                                                                                                        at com.facebook.react.bridge.JavaModuleWrapper.invoke(Unknown Source:147)
                                                                                                        at com.facebook.jni.NativeRunnable.run(Native Method)
                                                                                                        at android.os.Handler.handleCallback(Handler.java:938)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0)
                                                                                                        at android.os.Looper.loop(Looper.java:233)
                                                                                                        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source:37)
                                                                                                        at java.lang.Thread.run(Thread.java:923)
2023-10-14 14:49:37.255  6638-16423 Process                 com.bsuportal                        I  Sending signal. PID: 6638 SIG: 9
1

There are 1 best solutions below

0
On

@jaba can you try this solution i.e., by adding this lines in proguard file https://github.com/proyecto26/react-native-inappbrowser/issues/15#issuecomment-439477853