From 5822a0cda5071eca7315f681de0f53d44d9725d4 Mon Sep 17 00:00:00 2001 From: mariuskurgonas Date: Mon, 26 Feb 2024 23:31:28 +0000 Subject: [PATCH] chore: readme update --- README.md | 92 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 78 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index f4ed80e..446fe31 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,95 @@ # @getivy/react-native-sdk -Getivy SDK for React Native +# Getting Started -## Installation +- Installation +- Usage -```sh +## Step 1: Installation + +Add the module to your react native project by executing: + +```bash +# using npm npm install @getivy/react-native-sdk + +# OR using Yarn +yarn add @getivy/react-native-sdk +``` + +Create a personal Github access token with permission _read:packages_ and add the following in your Android application root _build.gradle_ file: + +``` +allprojects { + repositories { + maven { + name = "GitHub" + url = uri("https://maven.pkg.github.com/getivy/android-sdk-public") + credentials { + username = + password = + } + } + } + } ``` -## Usage +Even though the Maven repository is public, Github requires this to be able to get the package. -```js -import { multiply } from '@getivy/react-native-sdk'; +## Step 2: Usage -// ... +Import the package: -const result = await multiply(3, 7); ``` +import * as GetivySDK from '@getivy/react-native-sdk'; +``` + +Initialize the SDK with data session or checkout session id and environment: -## Contributing +``` +// Data session +GetivySDK.initializeDataSession(dataSessionId, "production"); +``` -See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow. +``` +// Checkout session +GetivySDK.initializeCheckoutSession(checkoutSessionId, "sandbox"); +``` -## License +Possible environment values: _production_ and _sandbox_ -MIT +Open SDK UI: + +``` +GetivySDK.openSDK(); +``` + +It will open a modal view on top of your application in iOS, and new activity in Android. + +Listen for SDK events: + +``` +import { NativeEventEmitter } from 'react-native'; + +// Component implementation + +useEffect(() => { + const eventEmitter = new NativeEventEmitter(eventsEmitter); + const onSuccess = eventEmitter.addListener('onSuccess', (eventData) => { + Alert.alert('Success', JSON.stringify(eventData)); + }); + + const onError = eventEmitter.addListener('onError', (eventData) => { + Alert.alert('Error', JSON.stringify(eventData)); + }); + + return () => { + onSuccess.remove(); + onError.remove(); + }; + }, []); +``` ---- +While going through SDK, closing, succeeding to pay or failing, events will be delivered by the listeners. -Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob) +Refer to the _example_ application for more indepth usage example.