Skip to content

Commit 09f3df4

Browse files
committed
user agent fix and more
1 parent 7e39c8e commit 09f3df4

File tree

9 files changed

+91
-151
lines changed

9 files changed

+91
-151
lines changed

Web3Webview.android.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,6 @@ export default class WebView extends React.Component {
480480

481481
onScroll = event => {
482482
const {onScroll} = this.props;
483-
onScroll && onScroll(event);
483+
onScroll && onScroll(event.nativeEvent);
484484
}
485485
}

Web3Webview.ios.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ class Web3Webview extends React.Component {
408408
);
409409
});
410410

411-
let source = this.props.source || {};
411+
let source = {...this.props.source} || {};
412412
if (typeof source == "object") {
413413
if(this.props.sendCookies){
414414
source.sendCookies = this.props.sendCookies;

android/.classpath

Lines changed: 0 additions & 6 deletions
This file was deleted.

android/.project

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<projectDescription>
3-
<name>android</name>
4-
<comment>Project android created by Buildship.</comment>
3+
<name>react-native-web3-webview</name>
4+
<comment>Project react-native-web3-webview created by Buildship.</comment>
55
<projects>
66
</projects>
77
<buildSpec>

android/.settings/org.eclipse.buildship.core.prefs

Lines changed: 0 additions & 2 deletions
This file was deleted.

android/src/main/java/com/web3webview/Web3WebviewManager.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public class Web3WebviewManager extends ReactWebViewManager {
137137
protected static final String BLANK_URL = "about:blank";
138138

139139
protected WebViewConfig mWebViewConfig;
140+
protected WebSettings mWebviewSettings;
140141
private static ReactApplicationContext reactNativeContext;
141142
private static boolean debug;
142143
private Web3WebviewPackage pkg;
@@ -515,7 +516,10 @@ public WebResourceResponse shouldInterceptRequest(WebResourceRequest request, Bo
515516
return null;
516517
}
517518
try {
519+
String ua = mWebviewSettings.getUserAgentString();
520+
518521
Request req = new Request.Builder()
522+
.header("User-Agent", ua)
519523
.url(urlStr)
520524
.build();
521525
Response response = httpClient.newCall(req).execute();
@@ -575,9 +579,14 @@ public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermiss
575579
settings.setBuiltInZoomControls(true);
576580
settings.setDisplayZoomControls(false);
577581
settings.setDomStorageEnabled(true);
582+
settings.setAllowFileAccess(true);
583+
settings.setAppCacheEnabled (true);
584+
settings.setLoadWithOverviewMode(true);
585+
settings.setAllowContentAccess(true);
586+
settings.setLoadsImagesAutomatically(true);
587+
settings.setBlockNetworkImage(false);
588+
settings.setBlockNetworkLoads(false);
578589

579-
settings.setAllowFileAccess(false);
580-
settings.setAllowContentAccess(false);
581590
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
582591
settings.setAllowFileAccessFromFileURLs(false);
583592
setAllowUniversalAccessFromFileURLs(webView, false);
@@ -611,6 +620,8 @@ public WebResourceResponse shouldInterceptRequest(WebResourceRequest request) {
611620
});
612621
}
613622

623+
mWebviewSettings = settings;
624+
614625
return webView;
615626
}
616627

ios/RNWeb3Webview.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,14 @@ - (instancetype)initWithProcessPool:(WKProcessPool *)processPool
7575
_automaticallyAdjustContentInsets = YES;
7676
_contentInset = UIEdgeInsetsZero;
7777
_scrollEventThrottle = 0.0;
78-
78+
79+
80+
7981
WKWebViewConfiguration* config = [[WKWebViewConfiguration alloc] init];
8082
config.processPool = processPool;
8183
WKUserContentController* userController = [[WKUserContentController alloc]init];
8284
[userController addScriptMessageHandler:[[WeakScriptMessageDelegate alloc] initWithDelegate:self] name:@"reactNative"];
85+
8386
config.userContentController = userController;
8487

8588
_webView = [[WKWebView alloc] initWithFrame:self.bounds configuration:config];
@@ -495,7 +498,7 @@ - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
495498

496499
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
497500
{
498-
[self scrollViewDidScroll:scrollView];
501+
[self scrollViewDidScroll:scrollView];
499502

500503
// Fire the end deceleration event
501504
_onMomentumScrollEnd([self getEventInfo:scrollView]);

package-lock.json

Lines changed: 0 additions & 117 deletions
This file was deleted.

package.json

Lines changed: 69 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,87 @@
11
{
2-
"name": "react-native-web3-webview",
3-
"version": "1.2.1",
4-
"description": "A react native webview optimized for a web3 dApp browser application",
5-
"main": "index.js",
6-
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
2+
"_from": "react-native-web3-webview@^1.2.0",
3+
"_id": "react-native-web3-webview@1.2.0",
4+
"_inBundle": false,
5+
"_integrity": "sha512-lKG6JqssbNTTzcXiou7IVyvJWpDem2EavtUsF+I6CaKvoMztMkOHVcLqngPYOnGg85CrTKrmgEqYeiPhHmbeBg==",
6+
"_location": "/react-native-web3-webview",
7+
"_phantomChildren": {},
8+
"_requested": {
9+
"type": "range",
10+
"registry": true,
11+
"raw": "react-native-web3-webview@^1.2.0",
12+
"name": "react-native-web3-webview",
13+
"escapedName": "react-native-web3-webview",
14+
"rawSpec": "^1.2.0",
15+
"saveSpec": null,
16+
"fetchSpec": "^1.2.0"
817
},
9-
"keywords": [
10-
"react",
11-
"native",
12-
"wkwebview",
13-
"webview",
14-
"ios",
15-
"android",
16-
"web3",
17-
"ethereum"
18+
"_requiredBy": [
19+
"/"
1820
],
21+
"_resolved": "https://registry.npmjs.org/react-native-web3-webview/-/react-native-web3-webview-1.2.0.tgz",
22+
"_shasum": "62202fadc25adfcec3ea55469b8e3a30c29674fb",
23+
"_spec": "react-native-web3-webview@^1.2.0",
24+
"_where": "/Users/bruno/repos/MetaMask",
1925
"author": {
2026
"name": "Bruno Barbieri",
2127
"email": "brunobar79@gmail.com"
2228
},
23-
"homepage": "https://github.com/brunobar79/react-native-web3-webview",
2429
"bugs": {
2530
"url": "https://github.com/brunobar79/react-native-web3-webview/issues"
2631
},
27-
"license": "MIT",
32+
"bundleDependencies": false,
2833
"dependencies": {
2934
"fbjs": "^0.8.3"
3035
},
36+
"deprecated": false,
37+
"description": "A react native webview optimized for a web3 dApp browser application",
38+
"homepage": "https://github.com/brunobar79/react-native-web3-webview",
39+
"keywords": [
40+
"react",
41+
"native",
42+
"wkwebview",
43+
"webview",
44+
"ios",
45+
"android",
46+
"web3",
47+
"ethereum"
48+
],
49+
"license": "MIT",
50+
"main": "index.js",
51+
"name": "react-native-web3-webview",
3152
"peerDependencies": {
3253
"prop-types": "^15.6.0",
3354
"react": "^16.0.0",
3455
"react-native": "^0.56.0"
56+
},
57+
"scripts": {
58+
"test": "echo \"Error: no test specified\" && exit 1"
59+
},
60+
"version": "1.2.0",
61+
"react-native": {
62+
"crypto": "react-native-crypto",
63+
"http": "@tradle/react-native-http",
64+
"https": "https-browserify",
65+
"os": "react-native-os",
66+
"_stream_transform": "readable-stream/transform",
67+
"_stream_readable": "readable-stream/readable",
68+
"_stream_writable": "readable-stream/writable",
69+
"_stream_duplex": "readable-stream/duplex",
70+
"_stream_passthrough": "readable-stream/passthrough",
71+
"stream": "stream-browserify",
72+
"vm": "vm-browserify"
73+
},
74+
"browser": {
75+
"crypto": "react-native-crypto",
76+
"http": "@tradle/react-native-http",
77+
"https": "https-browserify",
78+
"os": "react-native-os",
79+
"_stream_transform": "readable-stream/transform",
80+
"_stream_readable": "readable-stream/readable",
81+
"_stream_writable": "readable-stream/writable",
82+
"_stream_duplex": "readable-stream/duplex",
83+
"_stream_passthrough": "readable-stream/passthrough",
84+
"stream": "stream-browserify",
85+
"vm": "vm-browserify"
3586
}
36-
}
87+
}

0 commit comments

Comments
 (0)