Skip to content
This repository has been archived by the owner on Dec 3, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
chansuke authored Sep 28, 2018
2 parents c9a4e3e + 6cd521f commit 13b0933
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 20 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ in your react-native project, run `npm install react-native-webview-bridge --sav
import com.github.alinz.reactnativewebviewbridge.WebViewBridgePackage;
```

2. add the following code to add the package to `MainApplication.java`` (`MainActivity.java` if RN < 0.29)
2. add the following code to add the package to `MainApplication.java` (`MainActivity.java` if RN < 0.29)

```java
protected List<ReactPackage> getPackages() {
Expand Down Expand Up @@ -166,7 +166,7 @@ var Sample2 = createReactClass({
ref="webviewbridge"
onBridgeMessage={this.onBridgeMessage.bind(this)}
injectedJavaScript={injectScript}
source={{uri: "http://google.com"}}/>
source={{uri: "https://google.com"}}/>
);
}
});
Expand Down
10 changes: 0 additions & 10 deletions ios/RCTWebViewBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/

#import <UIKit/UIKit.h>

#import <React/RCTAutoInsetsProtocol.h>
#import <React/RCTConvert.h>
#import <React/RCTEventDispatcher.h>
#import <React/RCTLog.h>
#import <React/RCTUtils.h>
#import <React/RCTView.h>
#import <React/UIView+React.h>

#import <objc/runtime.h>

@class RCTWebViewBridge;

Expand Down
12 changes: 12 additions & 0 deletions ios/RCTWebViewBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@

#import "RCTWebViewBridge.h"

#import <UIKit/UIKit.h>

#import <React/RCTAutoInsetsProtocol.h>
#import <React/RCTConvert.h>
#import <React/RCTEventDispatcher.h>
#import <React/RCTLog.h>
#import <React/RCTUtils.h>
#import <React/RCTView.h>
#import "UIView+React.h"
#import <objc/runtime.h>

//This is a very elegent way of defining multiline string in objective-c.
//source: http://stackoverflow.com/a/23387659/828487
#define NSStringMultiline(...) [[NSString alloc] initWithCString:#__VA_ARGS__ encoding:NSUTF8StringEncoding]
Expand Down Expand Up @@ -87,6 +98,7 @@ - (void)sendToBridge:(NSString *)message
}
}());
);

// Escape singlequotes or messages containing ' will fail
NSString *quotedMessage = [message stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"];

Expand Down
1 change: 0 additions & 1 deletion ios/RCTWebViewBridgeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#import <React/RCTUIManager.h>
// #import <React/RCTBridge.h> // in forked https://github.com/lefnire/react-native-webview-bridge

#import "RCTWebViewBridge.h"

@interface RCTWebViewBridgeManager : RCTViewManager

Expand Down
6 changes: 5 additions & 1 deletion ios/RCTWebViewBridgeManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@

#import "RCTWebViewBridgeManager.h"

#import <React/RCTBridge.h>
#import <React/RCTUIManager.h>
#import "RCTWebViewBridge.h"
#import "UIView+React.h"

@interface RCTWebViewBridgeManager () <RCTWebViewBridgeDelegate>

@end
Expand Down Expand Up @@ -45,7 +50,6 @@ - (UIView *)view
RCT_EXPORT_VIEW_PROPERTY(onShouldStartLoadWithRequest, RCTDirectEventBlock)
RCT_REMAP_VIEW_PROPERTY(allowsInlineMediaPlayback, _webView.allowsInlineMediaPlayback, BOOL)
RCT_EXPORT_VIEW_PROPERTY(onBridgeMessage, RCTDirectEventBlock)
RCT_REMAP_VIEW_PROPERTY(keyboardDisplayRequiresUserAction, _webView.keyboardDisplayRequiresUserAction, BOOL)

- (NSDictionary<NSString *, id> *)constantsToExport
{
Expand Down
4 changes: 3 additions & 1 deletion webview-bridge/index.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
'use strict';

var React = require('react');
React.createClass = require('create-react-class');
var PropTypes = require('prop-types');
var ReactNative = require('react-native');
var createReactClass = require('create-react-class');
var invariant = require('invariant');
Expand All @@ -35,7 +37,7 @@ var {
WebViewBridgeManager
}
} = ReactNative;
var PropTypes = require('prop-types');
var { PropTypes } = PropTypes;

var RCT_WEBVIEWBRIDGE_REF = 'webviewbridge';

Expand Down
9 changes: 4 additions & 5 deletions webview-bridge/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
*/
'use strict';

// HACKFIX: https://github.com/facebook/metro-bundler/issues/74 - error: bundling failed: UnableToResolveError: Unable to resolve module `react` from `/Users/garyfung/Dropbox/Code/react-native-webview-bridge-RN0.40/webview-bridge/index.ios.js`: Module does not exist in the module map
// do same in node_modules/create-react-class/index.js on npm/yarn upgrade
// NOTE: metro bundler can't find react because node_modules symlink to this local package on ~/Dropbox?
var React = require('/Users/garyfung/Documents/code/WonderSwipe/node_modules/react');
var React = require('react');
React.createClass = require('create-react-class');
var PropTypes = require('prop-types');
var ReactNative = require('react-native');
var createReactClass = require('create-react-class');
var invariant = require('invariant');
Expand All @@ -38,7 +37,7 @@ var {
WebViewBridgeManager,
},
} = ReactNative;
var PropTypes = require('prop-types');
var { PropTypes } = PropTypes;

var BGWASH = 'rgba(255,255,255,0.8)';
var RCT_WEBVIEWBRIDGE_REF = 'webviewbridge';
Expand Down

0 comments on commit 13b0933

Please sign in to comment.