|
1 | 1 | # Hyper SDK React WebView
|
2 | 2 |
|
3 |
| -Custom webview for a hyper-sdk webview integration for react-native apps. |
| 3 | +A custom webview for integrating hyper-sdk with React Native apps. |
4 | 4 |
|
5 | 5 | ## Installation
|
6 | 6 |
|
| 7 | +To install using npm: |
| 8 | + |
7 | 9 | ```sh
|
8 | 10 | npm install hyper-sdk-react-webview
|
9 |
| - |
10 | 11 | ```
|
11 | 12 |
|
12 |
| - with `yarn` |
| 13 | +To install using yarn: |
13 | 14 |
|
14 | 15 | ```sh
|
15 | 16 | yarn add hyper-sdk-react-webview
|
16 |
| - |
17 | 17 | ```
|
18 | 18 |
|
19 |
| - **NOTE** please make sure that you have also installed `react-native-webview` as a dependency. Even though it's declared as a peer dependency, react-native doesn't pickup it's native-build files unless it's specified as a direct dependency of the app. |
| 19 | +**NOTE:** Ensure that `react-native-webview` is also installed as a dependency. Although it is declared as a peer dependency, React Native requires it to be a direct dependency to include its native build files. |
20 | 20 |
|
21 | 21 | ## Usage
|
22 | 22 |
|
23 |
| - Add our package repository to your app's `build.gradle` |
| 23 | +### Android |
| 24 | + |
| 25 | +Add our package repository to your app's `build.gradle`: |
| 26 | + |
24 | 27 | ```groovy
|
25 |
| -// .. |
26 | 28 | allprojects {
|
27 | 29 | repositories {
|
28 |
| - // .. |
29 | 30 | maven { url "https://maven.juspay.in/jp-build-packages/hyper-sdk/" }
|
30 | 31 | }
|
31 | 32 | }
|
32 | 33 | ```
|
33 | 34 |
|
34 |
| - Add the required intent handling in `MainActivity.kt` |
| 35 | +Add the required intent handling in `MainActivity.kt`: |
35 | 36 |
|
36 | 37 | ```kotlin
|
37 |
| - // ... |
38 |
| - override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { |
39 |
| - super.onActivityResult(requestCode, resultCode, data) |
40 |
| - if (requestCode == HyperWebViewManager.UPI_REQUEST_CODE) { |
41 |
| - HyperWebViewManager.onActivityResult(requestCode, resultCode, data) |
42 |
| - } |
| 38 | +override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { |
| 39 | + super.onActivityResult(requestCode, resultCode, data) |
| 40 | + if (requestCode == HyperWebViewManager.UPI_REQUEST_CODE) { |
| 41 | + HyperWebViewManager.onActivityResult(requestCode, resultCode, data) |
43 | 42 | }
|
| 43 | +} |
44 | 44 | ```
|
45 | 45 |
|
46 |
| - And then you can just start using it in react. |
| 46 | +### iOS |
| 47 | + |
| 48 | +Add URI schemes for required UPI apps in `Info.plist`: |
| 49 | + |
| 50 | +```plist |
| 51 | +<key>LSApplicationQueriesSchemes</key> |
| 52 | +<array> |
| 53 | + <string>credpay</string> |
| 54 | + <string>phonepe</string> |
| 55 | + <string>paytmmp</string> |
| 56 | + <string>tez</string> |
| 57 | + <string>paytm</string> |
| 58 | + <string>bhim</string> |
| 59 | + <string>myairtel</string> |
| 60 | +</array> |
| 61 | +``` |
| 62 | + |
| 63 | +Run `pod install` inside the iOS folder of your app. |
| 64 | + |
| 65 | +### React Native |
| 66 | + |
| 67 | +You can start using the component in your React Native app: |
47 | 68 |
|
48 | 69 | ```js
|
49 | 70 | import HyperWebView from 'hyper-sdk-react-webview';
|
50 | 71 |
|
51 |
| -// ... |
52 |
| - |
53 | 72 | const MyWebComponent = () => {
|
54 |
| - return <HyperWebView source={{ uri: 'https://reactnative.dev/' }} style={{ flex: 1 }} iframeIntegration={ false } />; |
| 73 | + return <HyperWebView source={{ uri: 'https://reactnative.dev/' }} style={{ flex: 1 }} iframeIntegration={false} />; |
55 | 74 | }
|
56 | 75 | ```
|
57 | 76 |
|
58 | 77 | ## How it works
|
59 | 78 |
|
60 |
| -With this package we have basically created a very thin wrapper around the `WebView` component provided by [react-native-webview](https://www.npmjs.com/package/react-native-webview). For `Android`, one can extend their view manager implementation & override the functionality as needed. After which the new class will have to be made available as a react-native component. |
| 79 | +This package provides a thin wrapper around the `WebView` component from [react-native-webview](https://www.npmjs.com/package/react-native-webview). For Android, you can extend the view manager implementation and override functionality as needed. The new class must then be made available as a React Native component. |
61 | 80 |
|
62 |
| -For a more detailed walk-through you can visit their docs: [Custom-Android.md](https://github.com/react-native-webview/react-native-webview/blob/v13.10.2/docs/Custom-Android.md) |
| 81 | +For a detailed walk-through, refer to their documentation: [Custom-Android.md](https://github.com/react-native-webview/react-native-webview/blob/v13.10.2/docs/Custom-Android.md). |
63 | 82 |
|
64 | 83 | ## License
|
65 | 84 |
|
66 | 85 | MIT
|
67 | 86 |
|
68 | 87 | ---
|
69 | 88 |
|
70 |
| -Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob) |
| 89 | +Created with [create-react-native-library](https://github.com/callstack/react-native-builder-bob) |
0 commit comments