Coder Social home page Coder Social logo

react-native-webview-bridge's Introduction

Please take a look at this issue first

React Native WebView Javascript Bridge

GitHub tag npm version GitHub license GitHub stars

I have been testing and reading a lot of way to safely create a bridge between react-native and webview. I'm happy to announced that the wait is over and from React-Native 0.20 and above, the bridge is fully functional.

Installation

In order to use this extension, you have to do the following steps:

in your react-native project, run npm install react-native-webview-bridge --save

iOS

  1. go to xcode's Project Navigator tab

2. right click on `Libraries` 3. select `Add Files to ...` option

4. navigate to `node_modules/react-native-webview-bridge/ios` and add `React-Native-Webview-Bridge.xcodeproj` folder

5. on project `Project Navigator` tab, click on your project's name and select Target's name and from there click on `Build Phases`

6. expand `Link Binary With Libraries` and click `+` sign to add a new one. 7. select `libReact-Native-Webviwe-Bridge.a` and click `Add` button.

8. clean compile to make sure your project can compile and build.

Android

  1. add the following import to MainApplication.java (MainActivity.java if RN < 0.29) of your application
import com.github.alinz.reactnativewebviewbridge.WebViewBridgePackage;
  1. add the following code to add the package to MainApplication.java (MainActivity.java if RN < 0.29)
protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
                new WebViewBridgePackage() //<- this
        );
    }
  1. add the following codes to your android/setting.gradle

you might have multiple 3rd party libraries, make sure that you don't create multiple include.

include ':app', ':react-native-webview-bridge'
project(':react-native-webview-bridge').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview-bridge/android')
  1. edit android/app/build.gradle and add the following line inside dependencies
compile project(':react-native-webview-bridge')
  1. run react-native run-android to see if everything is compilable.

Usage

just import the module with one of your choices way:

** CommonJS style **

var WebViewBridge = require('react-native-webview-bridge');

** ES6/ES2015 style **

import WebViewBridge from 'react-native-webview-bridge';

WebViewBridge is an extension of WebView. It injects special script into any pages once it loads. Also it extends the functionality of WebView by adding 1 new method and 1 new props.

sendToBridge(message)

the message must be in string. because this is the only way to send data back and forth between native and webview.

onBridgeMessage

this is a prop that needs to be a function. it will be called once a message is received from webview. The type of received message is also in string.

allowFileAccessFromFileURLs (Android only)

this is a prop that allows locally loaded pages via file:// to access other file:// resources. Pass-thru to corresponding setting in WebView. Default is false for Android 4.1 and above.

allowUniversalAccessFromFileURLs (Android only)

this is a prop that allows locally loaded pages via file:// to access resources in any origin. Pass-thru to corresponding setting in WebView. Default is false for Android 4.1 and above.

Bridge Script

bridge script is a special script which injects into all the webview. It automatically register a global variable called WebViewBridge. It has 2 optional methods to implement and one method to send message to native side.

send(message)

this method sends a message to native side. the message must be in string type or onError method will be called.

onMessage

this method needs to be implemented. it will be called once a message arrives from native side. The type of message is in string.

onError (iOS only)

this is an error reporting method. It will be called if there is an error happens during sending a message. It receives a error message in string type.

Notes

a special bridge script will be injected once the page is going to different URL. So you don't have to manage when it needs to be injected.

You can still pass your own javascript to be injected into webview. However, Bridge script will be injected first and then your custom script.

Simple Example

This example can be found in examples folder.

const injectScript = `
  (function () {
                    if (WebViewBridge) {

                      WebViewBridge.onMessage = function (message) {
                        if (message === "hello from react-native") {
                          WebViewBridge.send("got the message inside webview");
                        }
                      };
                
                      WebViewBridge.send("hello from webview");
                    }
                  }());
`;

var Sample2 = createReactClass({
  onBridgeMessage(message){
    const { webviewbridge } = this.refs;

    switch (message) {
      case "hello from webview":
        webviewbridge.sendToBridge("hello from react-native");
        break;
      case "got the message inside webview":
        console.log("we have got a message from webview! yeah");
        break;
    }
  },
  
  render() {
    return (
      <WebViewBridge
        ref="webviewbridge"
        onBridgeMessage={this.onBridgeMessage.bind(this)}
        injectedJavaScript={injectScript}
        source={{uri: "https://google.com"}}/>
    );
  }
});

react-native-webview-bridge's People

Contributors

agenthunt avatar alinz avatar amsul avatar antoniopresto avatar arstropica avatar benvium avatar bhullnatik avatar bilalbudhani avatar chansuke avatar corpuscallosum avatar danielapt avatar dozoisch avatar fungilation avatar graho23 avatar highruned avatar hmedney avatar hyusetiawan avatar ibandominguez avatar jakerawr avatar kevingrandon avatar kevlened avatar kishpatel1996 avatar maraujop avatar martnu avatar remstos avatar rick-li avatar rick-li-citi avatar saulshanabrook avatar stereodenis avatar tanguyantoine 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-webview-bridge's Issues

IFrame not supporting in webView Bridge

Hello,

I was tried to implement iFrame into webViewBridge but either it was crashing our app or showing black area. It is working fine with webView. We need asap this feature.

Thanks in Advance.

Tracking: Upgrade to [email protected]

It would be nice to be able to upgrade to [email protected]. I'm opening this to track the issue, and potentially investigate fixes.

There is an issue filed in the react-native project at: facebook/react-native#2010

In the meantime, we may be able to implement a retry workaround. @lightsofapollo commented there with,

Okay after a minimum of digging it turns out that it's a fairly simple race... It looks like pre 0.7 attempting to access viewRegistry for a particular reactTag was more deterministic (or the race was smaller) ... In my case I wrap my access to viewRegistry in a retry (which itself is only called in addUIBlock blocks).

Does not work in Android

'WebViewBridge' has no propType for native prop 'RCTWebViewBridge.source' of
native type 'Map'. If you haven't changed this prop yourself, this usually means that
your version of the native code and Javascript code are out of sync.
Updating both should make this error go away.

import WebViewBridge from 'react-native-webview-bridge';

screenshot_20160217-173245

WebViewBridge is undefined

  • I install react-native-webview-bridge following the installation, and run Sample1 APP successfully.
  • Then I create a page using WebViewBridgeReady and WebViewBridge.send just like the Example.
  • I modify the Example trying to send message manually by press a button.
  • But the document listener WebViewBridge is not triggered, and nothing is sent when I'm pressing the button.

I'm trying to figure out what has happened, then i found window.WebViewBridge is always undefined. Is there any step I've missed?

Maximum message size?

Is there a maximum message size for messages going to the webview? Small messages are getting through, but I don't receive messages a a few kilobytes in size.

[Android] injectScript not work!

I write bellow code:

function webViewBridgeReady(cb) {
if (window.WebViewBridge) {
cb(window.WebViewBridge);
return;
}

function handler() {
  document.removeEventListener('WebViewBridge', handler, false);
  cb(window.WebViewBridge);
}
document.addEventListener('WebViewBridge', handler, false);

}

function goDetail(id) {
WebViewBridge.send("jump:" + id);
}

webViewBridgeReady(function (webViewBridge) {
webViewBridge.send("message from webview");
});

the html is get from server, html have a button and click to invoke the goDetail function,but in android the
log cat say 'goDetail is not defined'.
can you help me?

NSUnknownKeyException

I get this error just by instantiating the WebViewBridge. The full error is:

2015-10-16 20:24:11.076 iphoneDEV[84420:4635019] *** WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: [<RCTWebView 0x7fd3ec0e4750> valueForUndefinedKey:]: this class is not key value coding-compliant for the key _eventDispatcher.

After digging around a bit I don't think that WebKit has actually anything to do with it. But I have no idea where this could come from.

I'm using react-native 0.13.0-rc

How can I open external links in safari.app from WebView?

Hello,

I am using this plugin, but I am facing one problem into webView. If there are external links into html content and we try to click on link it is replacing our content with new URL.
It should open in popup with close button or open in safari browser.
Have you noticed this issue?

I have inserted some patch into plugin but need to confirm from your side?

I am not a objective-s developer so please confirm if I am doing something wrong. My code is in else part.
Please review this function,

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    if (webView != _webView) { return YES; }
    NSURL *url = [request URL];
    __strong WVJB_WEBVIEW_DELEGATE_TYPE* strongDelegate = _webViewDelegate;
    if ([[url scheme] isEqualToString:kCustomProtocolScheme]) {
        if ([[url host] isEqualToString:kQueueHasMessage]) {
            [self _flushMessageQueue];
        } else {
            NSLog(@"WebViewJavascriptBridge: WARNING: Received unknown WebViewJavascriptBridge command %@://%@", kCustomProtocolScheme, [url path]);
        }
        return NO;
    } else if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:shouldStartLoadWithRequest:navigationType:)]) {
        return [strongDelegate webView:webView shouldStartLoadWithRequest:request navigationType:navigationType];
    } else {
      static NSString *regexp = @"^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9-]*[a-zA-Z0-9])[.])+([A-Za-z]|[A-Za-z][A-Za-z0-9-]*[A-Za-z0-9])$";
      NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regexp];

      if ([predicate evaluateWithObject:request.URL.host]) {
        [[UIApplication sharedApplication] openURL:request.URL];
        return NO;
      } else {
        return YES;
      }
//      return YES;
    }
}

How can I use WebViewBridge within ScrollView?

Hi -
I am trying to show multiple url's in a scroll view. Has anyone tried this or can help point out the problem?

<ScrollView>
    <WebViewBridge> </WebViewBridge>
    <AnotherComp/>
    <WebViewBridge> </WebViewBridge>
    <WebViewBridge> </WebViewBridge>
</ScrollView>

Unable to send messages through evalScript() logic

I am unable to send messages through evaluated scripts, since the latest version has landed. This was working before, but after the update it no longer works. I noticed that eval was changed to evalScript, and I'm wondering if this is still intended to work? My code looks like:

var myPageScripts = function() {
  function WebViewBridgeReady(cb) {
    if (window.WebViewBridge) {
      cb(window.WebViewBridge);
      return;
    }
    function handler() {
      document.removeEventListener('WebViewBridge', handler, false);
      cb(window.WebViewBridge);
    }
    document.addEventListener('WebViewBridge', handler, false);
  }
  WebViewBridgeReady(function (WebViewBridge) {
    WebViewBridge.send("Hello this is me calling from web page");
  });
};

// In react component
componentDidMount() {
  var webviewRef = this.refs.webView;
  var onMessage = function(message) {
    console.log("Received message", message);
  };
  webviewRef.onMessage(onMessage);

  var script = '(' + myPageScripts.toString() + '());';
  webviewRef.evalScript(script);
}

@alinz - Any ideas? Thank you!

[React native webView bridge] -

I am using this plugin to connect webView with my React Native code. I can send multiple messages from React Native to webView. But when I try to send message from webView to React native then I can send this only once. When I tried to send message again then it is showing error message. I tried hard to fix this but unable to fix. I am using same example as defined - I just added one button into HTML page to send multiple messages to React Native.
Please see attach screen shot.
ios simulator screen shot 23-jun-2015 17 23 31

Issue while sending JSON from react native to web by webview-bridge

Hello,

I am using your plugin from start. Previously it was working very fine but when I updated your latest version then I am facing below issues.

Issue1: If we send some simple json from react native to weView then it is working fine. But when I tried below JOSN (some dummy JSON) then it is not sending message to webView.

var data = {  
            content:'<p>Story: <a href="https://www.google.com">https://www.google.com</a>\n</p>\n<p>1.For - Close (i.e by \'X\') does not change to hyper-link - Delivered.\n</p>'
        }

Issue 2: I sent message as object but when I got this from web then it is showing as string.

Please can you check above issues?

Thanks in advance.

does not build on android (gradle error)

I updated to v0.20.0 but I'm afraid it does not change #53.

my updated setup :

  • "react-native": "0.20.0"
  • "react-native-webview-bridge": "0.20.0"

more info :
1- tested too in android studio and gradle was first still throwing this non sense (it can be so many things) error
- Configuration with name 'default' not found.

2- then configure a compile sdk in project structure and error changed a bit :

Error:(20, 0) Gradle DSL method not found: 'android()'
Possible causes:
 - The project 'android' may be using a version of Gradle that does not contain the method.
 - The build file may be missing a Gradle plugin.

I'm sorry I can't help more since I'm not as much at ease in Android as I am in iOS...

sendToBridge invalid

I don't understand why sendToBridge is used in setTimeout, and onLoadingFinish onLoadingStart onLoadingError is not valid.

Do you have a detailed documentation?

componentDidMount() {
    this.refs.webviewbridge.sendToBridge('message');  //invalid
    this.refs.webviewbridge.onLoadingStart(()=>{});   //invalid
    this.refs.webviewbridge.onLoadingFinish(()=>{});  //invalid
    this.refs.webviewbridge.onLoadingError(()=>{});   //invalid
    setTimeout(() => {
        //Why use delay?
        //Delay time can not be determined
        //Can there be a callback function, tell me to be able to use the correct sendToBridge
        this.refs.webviewbridge.sendToBridge('message'); //effective
    }, 1000);
}

Can not access `WebViewBridge` global variable from webview bridge file

Hello,

I created webviewBridge like:

var Sample2 = React.createClass({
  componentDidMount() {
    setTimeout(() => {
      this.refs.webviewbridge.sendToBridge("hahaha");
    }, 5000);
  },
  onBridgeMessage: function (message) {
    console.log(message);
  },
  render: function() {
    return (
      <WebViewBridge
        ref="webviewbridge"
        onBridgeMessage={this.onBridgeMessage}
        url="index.html"/>
    );
  }
});
<WebViewBridge ref="myWebView" onBridgeMessage={this.onBridgeMessage} url="index.html" />

how can I access webViewBridge from index.html?
My index.html file as below:

<html>
<head>
    <title>React App Comment stand alone page</title>
</head>
<body>
    <script type="text/javascript">
    connectWebViewJavascriptBridge: function(callback) {
        if (WebViewBridge) {
            callback(WebViewBridge);
            return;
        }
        if (window.WebViewBridge) {
            callback(window.WebViewBridge);
            return;
        }

        function handler() {
            document.removeEventListener('WebViewBridge', handler, false);
            callback(window.WebViewBridge);
        }
        document.addEventListener('WebViewBridge', handler, false);
    }
    </script>
</body>
</html>

Thanks in advance.

Crashes app while navigating webView pages from one to other

Hello,

I am facing crash issue with webView Bridge. When I navigate to webViewBridge page and before loading that page click on back button my app is crashing.
When I send quick messages from webView to react native its crashing too (with backspace - deleting content from webview textarea and sending content to react native on change).

Most of cases app is stuck into below line:
"" RCTLogMustFix(@"Invalid view returned from registry, expecting RKWebView, got: %@", view); ""

Full fucntion from file:

RCT_EXPORT_METHOD(callbackCleanup:(nonnull NSNumber *)reactTag)
{
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
RCTWebView *view = viewRegistry[reactTag];
if (![view isKindOfClass:[RCTWebView class]]) {
RCTLogMustFix(@"Invalid view returned from registry, expecting RKWebView, got: %@", view);
}

[view callbackCleanup:reactTag];

}];
}

Thanks in advance.

stops working after first time

Hi, I am using this component and I love it, but i noticed a very wired thing.
On the first time i go on a view that uses the bridge it works perfectly, but then after exploring the app and going into another view that uses the bridge it just won't work.

I use the bridge to open links in browser, while I'm on 'Debug with Chrome' mode it works perfectly, but when I'm not in debug mode it just starts making problems.

here is the code I'm injecting to the html:

var linker = function() {
  var links = document.getElementsByTagName('a');
  for(var i=0, length=links.length; i<length; i++) {
    links[i].onclick = function(e){
      e.preventDefault();
      window.WebViewBridge.send(this.href);
    };
  }
};

window.onload = function() {
  if (window.WebViewBridge) {
    linker()
  }
  else{
    document.addEventListener('WebViewBridge', linker, false);
  }
};

I am using react-native-route-flux, is it possible that it have something to do with moving between routes?

Maybe it's something you should consider about the mound and unmount of the component. It seems that it won't work after the first time it gets unmounted.

Update version to 0.7.0

Hi @alinz -

Thank you so much for the recent fixes. Just wanted to say that previously you had published v0.6.0, but then with the latest fixes the version changed to v0.3.0?

It seems like the easiest way to rectify this would be to publish a 0.7.0 version - let me know what you think.

Support html={} option

It'd be great if you did not have supply a url and you had the option to supply raw html.

Support file={} option

Similar to #38 - It would be nice to link to a local html file instead of pulling in a raw HTML string.

Ideally this would be able to link to other local resources (like additional js/css/images), but those could probably be inlined if necessary.

[Android] Cookies

How to save cookies in android when I close my app?

in ios I make extension:

//
//  NSHTTPCookieStorage+Persistence.m
//  WTCCEuroSport
//
//  Created by stereodenis on 19.02.16.
//  Copyright © 2016 Facebook. All rights reserved.
//
​
#import "NSHTTPCookieStorage+Persistence.h"static NSString *const kCookiesKey = @"cookies";
​
@implementation NSHTTPCookieStorage (Persistence)
​
- (void)saveToUserDefaults
{
  NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
  if (self.cookies != nil && self.cookies.count > 0) {
    NSData *cookieData = [NSKeyedArchiver archivedDataWithRootObject:self.cookies];
    [userDefaults setObject:cookieData forKey:kCookiesKey];
  } else {
    [userDefaults removeObjectForKey:kCookiesKey];
  }
  [userDefaults synchronize];
}
​
- (void)loadFromUserDefaults
{
  NSData *cookieData = [[NSUserDefaults standardUserDefaults] objectForKey:kCookiesKey];
  if (cookieData != nil) {
    NSArray *cookies = [NSKeyedUnarchiver unarchiveObjectWithData:cookieData];
    for (NSHTTPCookie *cookie in cookies) {
      [self setCookie:cookie];
    }
  }
}
​
- (void) clearCookies
{
 [[NSUserDefaults standardUserDefaults] removeObjectForKey:kCookiesKey];
  NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
  for (NSHTTPCookie *each in cookieStorage.cookies) {
    [cookieStorage deleteCookie:each];
  }
}
​
@end

and then in AppDelegate.m I do

- (void)applicationDidEnterBackground:(UIApplication *)application
{
  //Other existing code

  [self saveHTTPCookies];
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
  [self loadHTTPCookies];
}

- (void)applicationWillTerminate:(UIApplication *)application
{
  //Other existing code
  [self saveHTTPCookies];
}

- (void)loadHTTPCookies
{
  [[NSHTTPCookieStorage sharedHTTPCookieStorage] loadFromUserDefaults];
}

-(void)saveHTTPCookies

{
  [[NSHTTPCookieStorage sharedHTTPCookieStorage] saveToUserDefaults];
}

Request: Add support for injecting a user script

Stumbled across this project, thank you for the work here.

I think it would be really nice if there was some way to inject a user script into the webview. The idea is something like eval(), but having the content live in flat files. I think that this would make the library much easier to use.

The suggested api would be something like:

  componentDidMount() {
    var webviewRef = this.refs[WEBVIEW_REF];
    webviewRef.userScript('./path/to/file.js');
  }

WebViewManager.bridgeSetup is not a function

Hi alinz,
I use the version react-native ^0.12.0, but I have a problem similar with #12 .
Here is my settings and testing code, is there any details may I have missed?

issue

'use strict';

var React = require('react-native');
var WebViewBridgeNative = require('react-native-webview-bridge');

var myPageScripts = function() {
  function WebViewBridgeReady(cb) {
    if (window.WebViewBridge) {
      cb(window.WebViewBridge);
      return;
    }
    function handler() {
      document.removeEventListener('WebViewBridge', handler, false);
      cb(window.WebViewBridge);
    }
    document.addEventListener('WebViewBridge', handler, false);
  }
  WebViewBridgeReady(function (WebViewBridge) {
    WebViewBridge.send("Hello this is me calling from web page");
  });
};

//convert function definition into string
myPageScripts = `(${myPageScripts.toString()}());`;

var {
  AppRegistry,
  Component
} = React;

class testingBridge extends Component {
  constructor(props) {
    super(props);
    this.once = true;
  }

  componentDidMount() {
    var myWebViewBridgeRef = this.refs.myWebViewBridge;

    var onMessage = function(message) {
      console.log("Received message", message);
    };
    myWebViewBridgeRef.onMessage(onMessage);

    myWebViewBridgeRef.injectBridgeScript();

    //this opens up the printer window dialoge
    setTimeout(() => {
      myWebViewBridgeRef.print();
    }, 5000);
  }

  onNavigationStateChange(navState) {
    var myWebViewBridgeRef = this.refs.myWebViewBridge;
    if (this.once) {
      this.once = false;
      setTimeout(() => {
        myWebViewBridgeRef.evalScript(myPageScripts);
      }, 1000);
    }

    console.log(navState.url);
  }

  render() {
    var url = 'http://google.com';

    return (
      <WebViewBridgeNative
        ref="myWebViewBridge"
        onNavigationStateChange={this.onNavigationStateChange.bind(this)}
        url={url}
        style={{flex: 1}}/>
    );
  }
}

AppRegistry.registerComponent('testingBridge', () => testingBridge);

WebViewExManager.NavigationType error when starting project

Hi @alinz - I'm seeing some errors when trying to use this project, and I was wondering if you had any ideas.

2015-06-30 14:19:56.194 [error][tid:com.facebook.React.JavaScript] "Error: undefined is not an object (evaluating 'WebViewExManager.NavigationType')
stack:
index.ios.bundle:43155
require index.ios.bundle:244
index.ios.bundle:42219
require index.ios.bundle:244
index.ios.bundle:1110
require index.ios.bundle:244
applyWithGuard index.ios.bundle:880
require index.ios.bundle:195
index.ios.bundle:43383
URL: http://localhost:8081/index.ios.bundle
line: 43155

message: undefined is not an object (evaluating 'WebViewExManager.NavigationType')"
2015-06-30 14:19:56.245 [info][tid:com.facebook.React.JavaScript] "Running application "MyApp" with appParams: {"rootTag":1,"initialProps":{}}. DEV === true, development-level warning are ON, performance optimizations are OFF"

webView keyboard without arrows and "Done" button?

I know this is more React Native specific, but I figured a lot of people using the bridge would like to have this option.. Is there any way to disable the Arrows and 'Done' button above the keyboard in the webView?

I have a webView that loads a text editor that uses contentEditable text fields. But I have my own editor bar above the keyboard, and the safari bar above the keyboard makes it seem non-native.

Now it's like this: http://i.stack.imgur.com/Uz2Ly.png
But I want my own like this: http://www.geeky-gadgets.com/wp-content/uploads/2015/03/medium.jpg

I have found some solutions on how to do this, but I'm not able to implement it into the native code myself.

This code should work with iOS 9: http://stackoverflow.com/questions/19033292/ios-7-uiwebview-keyboard-issue/19042279#19042279

Here's a Cordova plugin that does the same (hideKeyboardAccessoryBar): https://github.com/driftyco/ionic-plugin-keyboard

React Native Access WebView Actions

How can I access webview function in react native When I use your plugin?
In my webview when i tapped a button , it will calls a function named onClick , I want to response to this function in react native . so what code should i write in my script? Can you give me any suggestion? , I try to inject a JavaScript like this

var myPageScripts = function() {
  function WebViewBridgeReady(cb) {
    if (window.WebViewBridge) {
      cb(window.WebViewBridge);
      return;
    }
    function handler() {
      document.removeEventListener('WebViewBridge', handler, false);
      cb(window.WebViewBridge);
    }
    document.addEventListener('WebViewBridge', handler, false);
  }
  WebViewBridgeReady(function (WebViewBridge) {
    WebViewBirdge.onMessage = {
      onClick : function() {
        WebViewBirdge.send("onClick")
      }
    }
  });
};
myPageScripts = `(${myPageScripts.toString()}());`;

broken with react-native 0.12 & 0.13?

To reproduce:

  • react-native init AwesomeProject
  • replace AwesomeProject#render with return <WebView style={{flex:1}} html="<html><body><h1>Hi</h1></body></html>" />;
  • run the project and notice it works
  • install react-native-webview-bridge as per instructions
  • run the project and notice the blank screen you get
  • npm install [email protected]
  • run the project and notice that it works

Notice that it's WebView that's broken, which is really surprising. Using WebViewBridge with or without injecting the bridge script doesn't help.

Push latest version to NPM.

Since the latest version fixed a bug that prevented actual usage it would be good if this version could be pushed to NPM.

Thanks for all the hard work!

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.