Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ReactNativeWebView_kotlinVersion=1.6.0
ReactNativeWebView_webkitVersion=1.4.0
ReactNativeWebView_webkitVersion=1.14.0
ReactNativeWebView_compileSdkVersion=31
ReactNativeWebView_targetSdkVersion=31
ReactNativeWebView_minSdkVersion=21
12 changes: 12 additions & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.reactnativecommunity.webview">

<queries>
<intent>
<action android:name="org.chromium.intent.action.PAY"/>
</intent>
<intent>
<action android:name="org.chromium.intent.action.IS_READY_TO_PAY"/>
</intent>
<intent>
<action android:name="org.chromium.intent.action.UPDATE_PAYMENT_DETAILS"/>
</intent>
</queries>

<application>
<provider
android:name=".RNCWebViewFileProvider"
Expand Down
13 changes: 13 additions & 0 deletions android/src/main/AndroidManifestNew.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<queries>
<intent>
<action android:name="org.chromium.intent.action.PAY"/>
</intent>
<intent>
<action android:name="org.chromium.intent.action.IS_READY_TO_PAY"/>
</intent>
<intent>
<action android:name="org.chromium.intent.action.UPDATE_PAYMENT_DETAILS"/>
</intent>
</queries>

<application>
<provider
android:name=".RNCWebViewFileProvider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -761,4 +761,11 @@ class RNCWebViewManagerImpl(private val newArch: Boolean = false) {
fun setWebviewDebuggingEnabled(viewWrapper: RNCWebViewWrapper, enabled: Boolean) {
RNCWebView.setWebContentsDebuggingEnabled(enabled)
}

fun setPaymentRequestEnabled(viewWrapper: RNCWebViewWrapper, enabled: Boolean) {
val view = viewWrapper.webView
if (WebViewFeature.isFeatureSupported(WebViewFeature.PAYMENT_REQUEST)) {
WebSettingsCompat.setPaymentRequestEnabled(view.settings, enabled)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,12 @@ public void setWebviewDebuggingEnabled(RNCWebViewWrapper view, boolean value) {
mRNCWebViewManagerImpl.setWebviewDebuggingEnabled(view, value);
}

@Override
@ReactProp(name = "paymentRequestEnabled")
public void setPaymentRequestEnabled(RNCWebViewWrapper view, boolean value) {
mRNCWebViewManagerImpl.setPaymentRequestEnabled(view, value);
}

/* iOS PROPS - no implemented here */
@Override
public void setAllowingReadAccessToURL(RNCWebViewWrapper view, @Nullable String value) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ public void setUserAgent(RNCWebViewWrapper view, @Nullable String value) {
mRNCWebViewManagerImpl.setUserAgent(view, value);
}

@ReactProp(name = "paymentRequestEnabled")
public void setPaymentRequestEnabled(RNCWebViewWrapper view, boolean value) {
mRNCWebViewManagerImpl.setPaymentRequestEnabled(view, value);
}

@Override
protected void addEventEmitters(@NonNull ThemedReactContext reactContext, RNCWebViewWrapper viewWrapper) {
// Do not register default touch emitter and let WebView implementation handle touches
Expand Down
14 changes: 12 additions & 2 deletions docs/Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ This document lays out the current public properties and methods for the React N
- [`lackPermissionToDownloadMessage`](Reference.md#lackPermissionToDownloadMessage)
- [`allowsProtectedMedia`](Reference.md#allowsProtectedMedia)
- [`webviewDebuggingEnabled`](Reference.md#webviewDebuggingEnabled)
- [`paymentRequestEnabled`](Reference.md#paymentRequestEnabled)

## Methods Index

Expand Down Expand Up @@ -1026,8 +1027,8 @@ Boolean value that indicates whether HTML5 videos can play Picture in Picture. T

> **NOTE**
>
> In order to restrict playing video in picture in picture mode this props need to be set to `false`
.
> In order to restrict playing video in picture in picture mode this props need to be set to `false`.

| Type | Required | Platform |
| ---- | -------- | -------- |
| bool | No | iOS |
Expand Down Expand Up @@ -1718,6 +1719,15 @@ Default is `false`. Supported on iOS as of 16.4, previous versions always allow
| ------- | -------- | -------- |
| boolean | No | iOS & Android |

### `paymentRequestEnabled`[⬆](#props-index)

Whether or not the webview has the Payment Request API enabled. Default is `false`.
This is needed for Google Pay to work within the WebView.

| Type | Required | Platform |
| ------- | -------- | -------- |
| boolean | No | Android |

## Methods

### `goForward()`[⬆](#methods-index)
Expand Down
16 changes: 16 additions & 0 deletions example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Messaging from './examples/Messaging';
import MultiMessaging from './examples/MultiMessaging';
import NativeWebpage from './examples/NativeWebpage';
import ApplePay from './examples/ApplePay';
import GooglePay from './examples/GooglePay';
import CustomMenu from './examples/CustomMenu';
import OpenWindow from './examples/OpenWindow';
import SuppressMenuItems from './examples/Suppress';
Expand Down Expand Up @@ -123,6 +124,14 @@ const TESTS = {
return <ApplePay />;
},
},
GooglePay: {
title: 'Google Pay ',
testId: 'GooglePay',
description: 'Test to open a Google Pay supported page',
render() {
return <GooglePay />;
},
},
CustomMenu: {
title: 'Custom Menu',
testId: 'CustomMenu',
Expand Down Expand Up @@ -250,6 +259,13 @@ export default class App extends Component<Props, State> {
onPress={() => this._changeTest('ApplePay')}
/>
)}
{Platform.OS === 'android' && (
<Button
testID="testType_googlePay"
title="GooglePay"
onPress={() => this._changeTest('GooglePay')}
/>
)}
<Button
testID="testType_customMenu"
title="CustomMenu"
Expand Down
22 changes: 22 additions & 0 deletions example/examples/GooglePay.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, {Component} from 'react';
import {View} from 'react-native';

import WebView from 'react-native-webview';

type Props = {};
type State = {};

export default class Alerts extends Component<Props, State> {
state = {};

render() {
return (
<View style={{ flex: 1 }}>
<WebView
source={{uri: "https://rsolomakhin.github.io/pr/gp2-test"}}
paymentRequestEnabled={true}
/>
</View>
);
}
}
1 change: 1 addition & 0 deletions src/RNCWebViewNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export interface NativeProps extends ViewProps {
}>;
userAgent?: string;
injectedJavaScriptObject?: string;
paymentRequestEnabled?: boolean;
}

export interface NativeCommands {
Expand Down
6 changes: 6 additions & 0 deletions src/WebViewTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ export interface CommonNativeWebViewProps extends ViewProps {
onShouldStartLoadWithRequest: (event: ShouldStartLoadRequestEvent) => void;
showsHorizontalScrollIndicator?: boolean;
showsVerticalScrollIndicator?: boolean;
paymentRequestEnabled?: boolean;
// TODO: find a better way to type this.

source: any;
Expand Down Expand Up @@ -1329,4 +1330,9 @@ export interface WebViewSharedProps extends ViewProps {
* Enables WebView remote debugging using Chrome (Android) or Safari (iOS).
*/
webviewDebuggingEnabled?: boolean;

/**
* Enables support for the Payment Request API for the WebView
*/
paymentRequestEnabled?: boolean;
}
Loading