-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f3fc69
commit 5822a0c
Showing
1 changed file
with
78 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = <Github_username> | ||
password = <Github_token> | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## 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. |