npm package: @loquis/react-native-sdk
Description: React Native wrapper for Loquis Mobile SDK (Android & iOS).
Author: Loquis
Latest version: 5.5.0-0


# react-native-loquis-sdk

React Native wrapper for the **Loquis Mobile SDK** (Android & iOS).

---

## Installation

```bash
npm install react-native-loquis-sdk
# or
yarn add react-native-loquis-sdk
```

### iOS only

```bash
cd ios && pod install
```

---

## API Key Setup (Required)

You must provide your `LOQUIS_API_KEY_JWS` when initializing the SDK.

We recommend using `react-native-config` to manage environment variables.

### 1. Install react-native-config

```bash
yarn add react-native-config
cd ios && pod install
```

### 2. Create a `.env` file in your project root

```
LOQUIS_API_KEY_JWS=your_api_key_here
```

After creating the `.env` file, rebuild the app.

---

## Private SDK Artifacts (S3 Access Required)

This React Native wrapper is public, but it downloads the underlying **Loquis SDK artifacts** from a private AWS S3 bucket:

- Android: Maven artifacts hosted on S3
- iOS: CocoaPods artifacts hosted on S3

To build the project, you must have AWS credentials with read access to the S3 bucket.

### Configure AWS credentials locally

Install AWS CLI and configure credentials:

```bash
aws configure
```

This creates:

- `~/.aws/credentials`
- `~/.aws/config`

Alternatively, export environment variables:

```bash
export AWS_ACCESS_KEY_ID="YOUR_ACCESS_KEY_ID"
export AWS_SECRET_ACCESS_KEY="YOUR_SECRET_ACCESS_KEY"
export AWS_DEFAULT_REGION="eu-west-1"
# If using temporary credentials:
export AWS_SESSION_TOKEN="YOUR_SESSION_TOKEN"
```

### CI Setup

In CI, store AWS credentials as secrets and export the same environment variables before running install/build steps.

---

## Initialization

```ts
import Config from 'react-native-config';
import { init } from 'react-native-loquis-sdk';

await init({
  apiKeyJws: Config.LOQUIS_API_KEY_JWS,
});
```

`init()` must be called before using any other SDK APIs or components.

---

## Usage Example

```tsx
import React, { useEffect, useRef } from 'react';
import { View } from 'react-native';
import {
  init,
  LoquisPlayer,
  getVersion,
  loquisListByPoint,
} from 'react-native-loquis-sdk';
import Config from 'react-native-config';

export default function App() {
  const playerRef = useRef(null);

  useEffect(() => {
    async function bootstrap() {
      await init({ apiKeyJws: Config.LOQUIS_API_KEY_JWS });

      const version = await getVersion();
      console.log('SDK version:', version);

      const result = await loquisListByPoint(44.4949, 11.3426);
      console.log(result);
    }

    bootstrap();
  }, []);

  return (
    <View style={{ flex: 1 }}>
      <LoquisPlayer style={{ height: 56 }} ref={playerRef} />
    </View>
  );
}
```

---

## Available APIs

### Initialize SDK

```ts
await init({ apiKeyJws: string });
```

### Get SDK version

```ts
const version = await getVersion();
```

### Fetch Loquis by point

```ts
const result = await loquisListByPoint(latitude, longitude);
```

### Fetch Loquis by bounds

```ts
const result = await loquisListByBounds({
  north,
  south,
  east,
  west,
  viewport: { width, height },
});
```

### Player Component

```tsx
<LoquisPlayer style={{ height: 56 }} />
```

---

## Notes

- The API key is required at runtime.
- AWS credentials are required at build time to download private SDK artifacts.
- After creating or modifying the `.env` file, rebuild the app.

---

## License

MIT