Giter Club home page Giter Club logo

react-native-crosswalk-webview-plus's Introduction

react-native-crosswalk-webview-plus

Crosswalk's WebView for React Native on Android.

thanks jordansexton,He developed the original project,but He hasn't been updated for two years so far (2018.9),and there are some bugs...,so I fix them and I add some new features.

but also,I'm so sorry,I have started to develop the app using Flutter,So I'm not maintaining the library anymore,thank you!

npm licence

Dependencies

  • react-native >=0.57.0, react >= 16.5.0

1. Installation

  • From the root of your React Native project
npm install react-native-crosswalk-webview-plus --save or
yarn add react-native-crosswalk-webview-plus
  • copy

node_modules/react-native-webview-crosswalk/libs/xwalk_core_library-23.53.589.4-arm.aar to your android/app/libs

2.Include module in your Android project

  • In android/setting.gradle
...
include ':CrosswalkWebView'
project(':CrosswalkWebView').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-crosswalk-webview-plus')

Include libs in your Android project

  • In android/build.gradle
...
allprojects {
    repositories {
        mavenLocal()
        jcenter()

        flatDir {          // <--- add this line
            dirs 'libs'    // <--- add this line
        }                  // <--- add this line
    }
}
  • In android/app/build.gradle
...
dependencies {
  ...
  implementation (name: "xwalk_core_library-23.53.589.4-arm", ext: "aar")     // <--- add this line
  implementation project(':CrosswalkWebView')                             // <--- add this line
}
  • Register package :
  • used add code into MainApplication.java
import com.jordansexton.react.crosswalk.webview.CrosswalkWebViewPackage;    // <--- add this line

public class MainApplication extends Application implements ReactApplication {
  ......

  @Override
  protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new CrosswalkWebViewPackage()    // <--- add this line
    );
  }

  ......

}

Notes

  • In development mode(yarn start) ,You should add the following code to MainApplication.java onCreate lifecyle
  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
    new XWalkView(this).onDestroy();  // just add this line for RN dev mode,and release mode you can delete it
  }

Because when you open the WebView page input box to enter text, app will crash,may be activity change ApplicationContext when activity onResume,so we need init XWalkView on Create,some variables may be static ,so it get value onCreate,and It's exactly what XWalkView runtime need. and I hope react-native can fix this for later version,and it happend in development mode,release mode is OK,so you can delete in release mode

  • The crosswalk.arr file I use only supports armeabi-v7a or armeabi 32 bit CPU, If you got this error
Java. Lang. RuntimeException: both Please have your activity extend XWalkActivity for Shared mode

maybe you should use others armeabi-v7a or armeabi cpu phone

features

1.props:

    injectedJavaScript:      PropTypes.string,
    localhost:               PropTypes.bool,
    onError:                 PropTypes.func,
    onMessage:               PropTypes.func,
    onNavigationStateChange: PropTypes.func,
    onProgress:              PropTypes.func,
    allowUniversalAccessFromFileURLs: PropTypes.bool,
    domStorageEnabled: PropTypes.bool,
    mediaPlaybackRequiresUserAction:PropTypes.bool,
    javaScriptEnabled:PropTypes.bool,
    userAgent:PropTypes.string,
    scalesPageToFit:PropTypes.bool,
    saveFormDataDisabled:PropTypes.bool,
    source:                  PropTypes.oneOfType([
      PropTypes.shape({
        uri: PropTypes.string,  // URI to load in WebView
      }),
      PropTypes.shape({
        html: PropTypes.string, // static HTML to load in WebView
      }),
      PropTypes.number,           // used internally by React packager
    ]),
    url:PropTypes.string,

methods:

goBack(){}
goForward(){}
reload(){}
load(url:string){}
postMessage(data:any){}

useages:

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow
 */

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
import { RCTCrossWalkWebView } from 'react-native-crosswalk-webview-plus'

const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
  android:
    'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});

type Props = {};
export default class App extends Component<Props> {
  render() {
    return (
      <View style={styles.container}>
      	<View >
          <RCTCrossWalkWebView style={{width:500,flex:1}}  source={{uri:'https://www.baidu.com'}}/>
	</View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

License

MIT

react-native-crosswalk-webview-plus's People

Contributors

fantasy525 avatar waterloobridge avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-native-crosswalk-webview-plus's Issues

fullscreen is not working

I have a video player in the page, and i want to view it in a fullscreen.
currently when i click on fullscreen, the player take 100% of the height i gave toCrosswalkWebview, is there an option to make it takes the phone height?

How to use this?

Can you add please a section explaining how to use this. or we can just import WebView from react-native and it will automatically use crosswalk webview instead of the original one

Error via PhoneGap

Tried using the plugin at PhoneGap, but the error I got was that "plugin.xml could not be found".

WebView crashing when entering text in input field

I'm using this webview in my project, and though it has helped improved performance generally, I am facing a critical issue. Whenever I highlight any input field on the web page and enter text, the app crashes. The following is the log, please help:

07-06 22:28:28.107 my.package.name 28600 29068 F libc Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 29068 (Chrome_InProcRe), pid 28600 (ters.in.android) 07-06 22:28:28.278 31234 - F crash_dump64 *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 07-06 22:28:28.278 31234 - F crash_dump64 Build fingerprint: 'google/walleye/walleye:8.1.0/OPM1.171019.011/4448085:user/release-keys' 07-06 22:28:28.278 31234 - F crash_dump64 Revision: '0' 07-06 22:28:28.278 31234 - F crash_dump64 ABI: 'arm64' 07-06 22:28:28.278 31234 - F crash_dump64 pid: 28600, tid: 29068, name: Chrome_InProcRe >>> my.package.name <<< 07-06 22:28:28.278 31234 - F crash_dump64 signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 07-06 22:28:28.278 31234 - F crash_dump64 Cause: null pointer dereference 07-06 22:28:28.278 31234 - F crash_dump64 x0 0000000000000000 x1 4e0c5ae2146e7b1d x2 4e0c5ae2146e7b1d x3 0000007a068ba9f0 07-06 22:28:28.278 31234 - F crash_dump64 x4 0000007951afe7b8 x5 0000007951afead4 x6 4f505f5321300117 x7 0000000007909d1c 07-06 22:28:28.278 31234 - F crash_dump64 x8 0000000000000000 x9 0000000000000002 x10 0000000000000001 x11 0000000000000000 07-06 22:28:28.278 31234 - F crash_dump64 x12 0000000000000003 x13 ffffffffffffffff x14 ffffffff00000000 x15 ffffffffffffffff 07-06 22:28:28.278 31234 - F crash_dump64 x16 0000007956c1de68 x17 0000007a06848208 x18 00000000fff6f3b2 x19 0000000000000001 07-06 22:28:28.278 31234 - F crash_dump64 x20 0000007951afec5c x21 0000007951afec58 x22 0000007951affe7e x23 0000007951afec60 07-06 22:28:28.279 31234 - F crash_dump64 x24 0000000000000001 x25 0000000000000001 x26 0000000000000000 x27 0000007951afecff 07-06 22:28:28.279 31234 - F crash_dump64 x28 0000000000000000 x29 0000007951afebc0 07-06 22:28:28.279 31234 - F crash_dump64 sp 0000007951afebc0 lr 0000007955ef02d4 pc 0000007955ef02d4 07-06 22:28:28.285 31234 - F crash_dump64 07-06 22:28:28.285 31234 - F crash_dump64 backtrace: 07-06 22:28:28.285 31234 - F crash_dump64 #00 pc 0000000002dcf2d4 /data/app/my.package.name-YySnZ8rkcGdNNWlHU43E7w==/lib/arm64/libxwalkcore.so 07-06 22:28:29.384 tombstoned 590 - E /system/bin/tombstoned Tombstone written to: /data/tombstones/tombstone_02 07-06 22:28:29.403 lmkd 515 - E lowmemorykiller Error writing /proc/28600/oom_score_adj; errno=22

Element type is invalid

How to solve Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined problem?
Thanks

Please have your activity extend XWalkActivity for shared mode

Hi, everybody!

I have the latest version of xwalk library: 23.53.589.4
I did everything as written in readme.md.
Added new XWalkView (getApplicationContext ()). OnDestroy (); And on this line falls error:
java.lang.RuntimeException: Please have your activity extend XWalkActivity for shared mode
Please tell me what to do, how to fix the error and start the application. Maybe there are examples of working applications. Share them, I will be grateful.

Best regards.
Yury

Control caching by url / extension

Hi, I'm trying out this Crosswalk WebView implementation and apart from some problems from listeners (which I'm sure I can manage) its all going well.

However, there is one problem for which I'm unable to proceed. This WebView is caching html's and uses stale versions when it should not (in my app). I appreciate caching for most other types of resources (Images, JS, CSS, Fonts, etc) and want to cache these extensions. Is there way to / do you plan on adding a way to control the caching?

TargetsdkVersion > 23 and ANIMATABLE_XWALK_VIEW cause a Build Crash

I'm using Webview as Textureview ((XwalkPreferences.setValue(XWalkPreferences.ANIMATABLE_XWALK_VIEW, true); flag) but I'm not able to build project with targetSdkVersion > 23.

Caused by: java.lang.RuntimeException: java.lang.UnsupportedOperationException: TextureView doesn't support displaying a background drawable at org.xwalk.core.ReflectConstructor.newInstance(ReflectConstructor.java:54) at org.xwalk.core.XWalkView.reflectionInit(XWalkView.java:2082) at org.xwalk.core.XWalkView.<init>(XWalkView.java:261)

(without this flag, Webview is SurfaceView - it's hard to create bitmap from it)

I need this flag to grab screenshot of Webview. Is there other way to grab screenshot and build with target > 23 ?

H5不能收到postMessage消息,JS代码要怎么写

RN invoke postMessage method.
RN代码调用 postMessage 方法

H5 can not Intercept by window.addListener('message', res => {}) and document.addListener('message', res => {})
通过 H5 的 window.addListener('message', res => {})document.addListener('message', res => {}) 不能拦截到RN的消息

How can I intercept events of RN in H5?
请问大佬H5中怎样才能拦截RN的消息

3q

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.