react-native-inappbrowser for Android

pes8fvy9  于 2023-11-21  发布在  React
关注(0)|答案(1)|浏览(173)

我在ReactNative中有一个应用程序,它使用webview来加载URL,我试图用inappbrowser-reborn打开该URL中的URL,但当我在真实的设备上用npm run android运行项目时,我得到了这个错误。inappbrowser-reborn不会过期并关闭我是这个问题的新手,请找到修复它的方法这是我试图打开inappbrowser的Index.js代码片段

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'
       }

字符串

但应用程序关闭,我在android studio日志中得到此错误

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

yzuktlbb

yzuktlbb1#

@jaba你可以尝试这个解决方案,即,通过在proguard文件中添加这行https://github.com/proyecto26/react-native-inappbrowser/issues/15#issuecomment-439477853

相关问题