# SEON Mobile SDK React Native Wrapper

This package provides a React Native wrapper for the SEON Mobile SDK, allowing you to integrate SEON's Device Intelligence module into your React Native projects. It supports both Android and iOS platforms.

## Installation

Install the package in your existing React Native project:

```bash
npm install @seontechnologies/seon-react-native-mobile-wrapper
```

## Usage

Import the SEON wrapper in your JavaScript files:

```javascript
import { SeonReactNativeMobileWrapper as Seon } from "@seontechnologies/seon-react-native-mobile-wrapper";
```

### Basic Usage

Here's a basic example of how to use the SEON wrapper:

```javascript
// Replace 'YOUR_UNIQUE_SESSION_ID' with your actual session identifier.
await Seon.setSessionId("YOUR_UNIQUE_SESSION_ID");

// Enable logging (optional)
await Seon.setLoggingEnabled(true);

// Generate fingerprint
try {
  const fingerprint = await Seon.getFingerprintBase64();
  // Send 'fingeprint' to your backend and use it as the session property
  // for your Fraud API request.
} catch (error) {
  // Handle errors
}
```

### Behaviour Monitoring

The SEON SDK can monitor user behaviour to collect behaviour-based signals. It's recommended to run the monitoring for at least a few seconds to gather sufficient data.

### Starting Behaviour Monitoring

```javascript
await Seon.startBehaviourMonitoring();
// Stopping Behaviour Monitoring
try {
  const behaviourData = await Seon.stopBehaviourMonitoring();
  // Send 'behaviourData' to your backend and use it as the session property
  // for your Fraud API request.
} catch (error) {
  // Handle errors
}
```

### Geolocation Configuration

The SEON SDK supports geolocation services. You can configure these services using the `SeonGeolocationConfig` interface:

### Permissions

Ensure that your application has the necessary permissions to access location services. Update your app's configuration files and request permissions at runtime.

### iOS

Add the following keys to your Info.plist file with appropriate usage descriptions:

- NSLocationWhenInUseUsageDescription
- NSLocationAlwaysAndWhenInUseUsageDescription (if needed)

### Android

Add the following permissions to your AndroidManifest.xml:

```xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
```

> ### **Note**: Remember to request location permissions at runtime.

### Enabling Geolocation Services

```typescript
await Seon.setGeolocationEnabled(true);
```

OR

```typescript
const geolocationConfig = {
  prefetchEnabled: true,
  geolocationServiceTimeoutMs: 5000, // in milliseconds
  maxGeoLocationCacheAgeSec: 300, // in seconds
  geolocationEnabled: true,
};

await Seon.setGeoLocationConfig(geolocationConfig);
```

- `prefetchEnabled`: When enabled, SEON pre-fetches location on creation of a SeonReactNativeMobileWrapper object for better performance.
- `geolocationServiceTimeoutMs`: Network timeout for SEON's geolocation services in milliseconds. Default is 3000.
- `maxGeoLocationCacheAgeSec`: Maximum location data age permitted in seconds. Default is 600.
- `geolocationEnabled`: Enables or disables SEON's geolocation services.

## Platform Specific Notes

- Make sure you have the necessary permissions set up in your Android and iOS projects for geolocation services if you plan to use them.

## Error Handling

All methods return promises, so you can use try-catch blocks or .catch() to handle any errors that might occur during the SDK operations. For the possible errors and statuses please visit the SDK repositories.

> **Please note that if a Geolocation error occur, the SDK should still return a valid fingerprint object which can be used as the session property for the regular Fraud API requests if needed.**

## Additional Information

For more detailed information about the iOS and Android SDKs, please refer to their respective GitHub repositories:

- [SEON iOS SDK](https://github.com/seontechnologies/seon-ios-sdk-public)
- [SEON Android SDK](https://github.com/seontechnologies/seon-android-sdk-public)

## Support

If you encounter any issues or have questions about the SEON Mobile SDK React Native Wrapper, please contact SEON support or refer to the official SDK documentations.

## Release Notes

### 3.3.4

- Supports Android SDK version: `6.8.2`. For the changelog visit: https://github.com/seontechnologies/seon-android-sdk-public#682

### 3.3.3

- Supports iOS SDK version: `5.6.3` For the changelog visit: https://github.com/seontechnologies/seon-ios-sdk-public#563

### 3.3.2

- Removed the following permissions from our `AndroidManifest.xml`:

  > **Note:** If you depend any of the optional features connected to these permissions, from this version onwards you need to add them to your `AndroidManifest.xml` manually

  > Please, read carefully what features are connected to these permissions in our Android SDK public documentation's [Requirements section](https://github.com/seontechnologies/seon-android-sdk-public?tab=readme-ov-file#requirements)
  - `android.permission.ACCESS_FINE_LOCATION`
  - `android.permission.ACCESS_COARSE_LOCATION`
  - `android.permission.READ_PHONE_STATE`
  - `android.permission.READ_PHONE_NUMBERS`

- Supports Android SDK version: `6.8.1`. For the changelog visit: https://github.com/seontechnologies/seon-android-sdk-public#681

### 3.3.1

- ⚠️ **IMPORTANT! This version includes necessary fixes to be compliant and compatible with iOS 26!** ⚠️
- Supports iOS SDK version: `5.6.2` For the changelog visit: https://github.com/seontechnologies/seon-ios-sdk-public#562

### 3.3.0

- Added 16 KB page size support to ensure Google Play compatibility beyond November 1st, 2025. Please carefully read the [related documentation](https://github.com/seontechnologies/seon-android-sdk-public?tab=readme-ov-file#16-kb-page-size-compatibility-on-google-play)!
- Supports Android SDK version: `6.8.0`. For the changelog visit: https://github.com/seontechnologies/seon-android-sdk-public#680
- Supports iOS SDK version: `5.6.1` For the changelog visit: https://github.com/seontechnologies/seon-ios-sdk-public#561
- Added fixes and improvements

### 3.2.1

- Upgraded to Android SDK v6.7.0. For more detailed change logs please visit the [SDK repository](https://github.com/seontechnologies/seon-android-sdk-public#670).
- Upgraded to iOS SDK v5.6.0. For more detailed change logs please visit the [SDK repository](https://github.com/seontechnologies/seon-ios-sdk-public#560).
- Fixed Old Architecture bug when there's no explicit geolocation config set.

### 3.2.0

> **IMPORTANT**: Introduces support for React's New Architecture. The module has been tested with React Native v0.78.0

- Upgraded to Android SDK v6.6.1. For more detailed change logs please visit the [SDK repository](https://github.com/seontechnologies/seon-android-sdk-public#661).
- Upgraded to iOS SDK v5.5.2. For more detailed change logs please visit the [SDK repository](https://github.com/seontechnologies/seon-ios-sdk-public#552).
- Internal changes to support the New Architecture.

### 3.1.0

> **IMPORTANT**: This version is going to introduce a new Fraud API response field named true_device_id.

- Upgraded to Android SDK v6.6.0. For more detailed change logs please visit the [SDK repository](https://github.com/seontechnologies/seon-android-sdk-public#660).
- Upgraded to iOS SDK v5.5.1. For more detailed change logs please visit the [SDK repository](https://github.com/seontechnologies/seon-ios-sdk-public#551).
- Unified GeolocationConfig object, it now has full availability on iOS as well.
- Added geolocationEnabled chain to the configuration builder on Android.
- Unified error messages.
- Added status codes to error messages.
- Added support to SEON's Geofence API.
