diff --git a/README.md b/README.md index b1659587..35140d47 100644 --- a/README.md +++ b/README.md @@ -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 getPackages() { @@ -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"}}/> ); } }); diff --git a/ios/RCTWebViewBridge.h b/ios/RCTWebViewBridge.h index 95162d3b..c7d34222 100644 --- a/ios/RCTWebViewBridge.h +++ b/ios/RCTWebViewBridge.h @@ -10,17 +10,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#import - -#import -#import -#import -#import -#import #import -#import - -#import @class RCTWebViewBridge; diff --git a/ios/RCTWebViewBridge.m b/ios/RCTWebViewBridge.m index e01c120d..d26a6a9d 100644 --- a/ios/RCTWebViewBridge.m +++ b/ios/RCTWebViewBridge.m @@ -12,6 +12,17 @@ #import "RCTWebViewBridge.h" +#import + +#import +#import +#import +#import +#import +#import +#import "UIView+React.h" +#import + //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] @@ -87,6 +98,7 @@ - (void)sendToBridge:(NSString *)message } }()); ); + // Escape singlequotes or messages containing ' will fail NSString *quotedMessage = [message stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"]; diff --git a/ios/RCTWebViewBridgeManager.h b/ios/RCTWebViewBridgeManager.h index 3827b098..1a36ee7c 100644 --- a/ios/RCTWebViewBridgeManager.h +++ b/ios/RCTWebViewBridgeManager.h @@ -14,7 +14,6 @@ #import // #import // in forked https://github.com/lefnire/react-native-webview-bridge -#import "RCTWebViewBridge.h" @interface RCTWebViewBridgeManager : RCTViewManager diff --git a/ios/RCTWebViewBridgeManager.m b/ios/RCTWebViewBridgeManager.m index 6a1ff434..0feab1d8 100644 --- a/ios/RCTWebViewBridgeManager.m +++ b/ios/RCTWebViewBridgeManager.m @@ -12,6 +12,11 @@ #import "RCTWebViewBridgeManager.h" +#import +#import +#import "RCTWebViewBridge.h" +#import "UIView+React.h" + @interface RCTWebViewBridgeManager () @end @@ -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 *)constantsToExport { diff --git a/webview-bridge/index.android.js b/webview-bridge/index.android.js index bb9fa8e1..e9f5db4d 100644 --- a/webview-bridge/index.android.js +++ b/webview-bridge/index.android.js @@ -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'); @@ -35,7 +37,7 @@ var { WebViewBridgeManager } } = ReactNative; -var PropTypes = require('prop-types'); +var { PropTypes } = PropTypes; var RCT_WEBVIEWBRIDGE_REF = 'webviewbridge'; diff --git a/webview-bridge/index.ios.js b/webview-bridge/index.ios.js index cf68d4a6..4e1db351 100644 --- a/webview-bridge/index.ios.js +++ b/webview-bridge/index.ios.js @@ -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'); @@ -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';