0.4.0 • Published 10 months ago
@rentlydev/react-native-bridge v0.4.0
@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
npm install @rentlydev/react-native-bridgeor
yarn add @rentlydev/react-native-bridgeConfiguration and Permissions
No permissions needed
Summary
Methods
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
<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>import { PackageManager } from '@rentlydev/react-native-bridge';
await PackageManager.isPackageInstalled("com.example.package") // true or falseiOS
Add below to Info.plist
<key>LSApplicationQueriesSchemes</key>
<array>
<string>appScheme</string>
</array>import { PackageManager } from '@rentlydev/react-native-bridge';
await PackageManager.isPackageInstalled("appScheme://") // true or falsegetPackageFingerprint(packageName) (Only For Android)
If >= Android 11 (API level 30) and below to AndroidManifest.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>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:25setResultAndFinish(result, extras) (Only For Android)
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
- Clone the repository
- Do
yarn install - Next navigate to example folder i.e
cd example - Do
yarn install - Next navigate to ios folder i.e
cd iosand dopod install, thencd .. - For android run
yarn android - For ios run
yarn ios