npm package: @rentlydev/react-native-bridge
Description: Bridge for native Api's
Author: HarshaR1642
Latest version: 0.4.0

[![npm](https://img.shields.io/npm/v/@rentlydev/react-native-bridge.svg)](https://npmjs.com/@rentlydev/react-native-bridge) [![React Native](https://img.shields.io/badge/React_Native-21232a?style=flat&logo=react&logoColor=0a7ea4&logoSize=small.svg)]() [![Android](https://img.shields.io/badge/Android-green?style=flat&logo=android&logoColor=white)]() [![iOS](https://img.shields.io/badge/iOS-21232a?style=flat&logo=ios&logoColor=white)]()

# @rentlydev/react-native-bridge

This React Native package provides a bridge for accessing native APIs, enabling seamless integration between React Native and platform-specific features that aren't directly available in the React Native ecosystem. By leveraging this bridge, developers can invoke native functions from JavaScript, offering a more extensive range of capabilities for their apps.

Fully compatible with TypeScript.

## Supported platforms

| Platform  |  Support |
|---|---|
| iOS  |  ✅ |
| Android  |  ✅ |
| Web  |  ❌ |
| Windows  |  ❌ |
| macOS  |  ❌ |

## Installation

```sh
npm install @rentlydev/react-native-bridge
```
or

```sh
yarn add @rentlydev/react-native-bridge
```

## Configuration and Permissions

No permissions needed

## Summary

### Methods

* [`isPackageInstalled`](#isPackageInstalled)
* [`getPackageFingerprint`](#getPackageFingerprint)
* [`setResultAndFinish`](#setResultAndFinish)

---

## Usage

### isPackageInstalled(packageName)
To find if the app is installed on the device

### Android
If >= Android 11 (API level 30) and below to `AndroidManifest.xml`
```xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

  <queries>
    <package android:name="com.example.package" /> // Add the package that you want to query
  </queries>

</manifest>
```

```javascript
import { PackageManager } from '@rentlydev/react-native-bridge';
await PackageManager.isPackageInstalled("com.example.package") // true or false
```
### iOS
Add below to `Info.plist`
```xml
<key>LSApplicationQueriesSchemes</key>
<array>
  <string>appScheme</string>
</array>
```

```javascript
import { PackageManager } from '@rentlydev/react-native-bridge';
await PackageManager.isPackageInstalled("appScheme://") // true or false
```

### getPackageFingerprint(packageName) (Only For Android)
If >= Android 11 (API level 30) and below to `AndroidManifest.xml`
```xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

  <queries>
    <package android:name="com.example.package" /> // Add the package that you want to get fingerprint
  </queries>

</manifest>
```

```javascript
import { PackageManager } from '@rentlydev/react-native-bridge';
const response = await PackageManager.getPackageFingerprint("com.example.package")
// 2F:19:AD:EB:28:4E:B3:6F:7F:07:78:61:52:B9:A1:D1:4B:21:65:32:03:AD:0B:04:EB:BF:9C:73:AB:6D:76:25
```

### setResultAndFinish(result, extras) (Only For Android)
```javascript
import { ActivityManager } from '@rentlydev/react-native-bridge';
result = "ok" or "cancel"
extras = { string: number | string | boolean }
ActivityManager.setResultAndFinish(result, extras)
```

## How To Run Example App ?

To run example app, follow the below steps

1. Clone the repository
2. Do `yarn install`
3. Next navigate to example folder i.e `cd example`
4. Do `yarn install`
5. Next navigate to ios folder i.e `cd ios` and do `pod install`, then `cd ..`
6. For android run `yarn android`
7. For ios run `yarn ios`