@prosquad/react-native-sdk
v0.1.0
Published
Prosquad rider delivery SDK for React Native (Android only)
Maintainers
Readme
@prosquad/react-native-sdk
Android-only React Native SDK that embeds the Prosquad rider delivery flow into your app. The delivery UI runs in a full-screen native WebView with native integrations for location tracking, camera, QR scanning, and push notifications. Authentication is handled internally via OTP — no external auth token is needed.
Requirements
- React Native >= 0.60.0
- Android only (minSdk 24 / Android 7.0)
Installation
npm install @prosquad/react-native-sdk
# or
yarn add @prosquad/react-native-sdkThe library supports React Native autolinking — no manual native setup is required.
Android Permissions
The SDK declares the following permissions in its manifest (merged automatically):
INTERNETACCESS_FINE_LOCATION/ACCESS_COARSE_LOCATION/ACCESS_BACKGROUND_LOCATIONCAMERAFOREGROUND_SERVICE(location)POST_NOTIFICATIONS
Your app must request runtime permissions for location, camera, and notifications as appropriate.
Push Notifications (Firebase)
The SDK does not include Firebase itself. Your host app should integrate @react-native-firebase/messaging and forward notifications to the SDK (see usage below).
Usage
import * as ProsquadSDK from '@prosquad/react-native-sdk';Launch the delivery flow
await ProsquadSDK.launch(
{
eid: 'your-enterprise-id',
phoneNumber: '+919876543210',
hostUserId: 'user-123',
riderName: 'John Doe', // displayed in the delivery UI
city: 'Bangalore',
},
{
onOrderComplete: (orderId, status) => {
console.log(`Order ${orderId} completed with status: ${status}`);
},
onClose: () => {
console.log('Delivery flow closed');
},
onNotificationReceived: (type, data) => {
console.log('Notification received:', type, data);
},
},
);Register FCM token
import messaging from '@react-native-firebase/messaging';
const token = await messaging().getToken();
await ProsquadSDK.registerDeviceToken(token);Handle push notifications
// Background/quit handler
messaging().setBackgroundMessageHandler(async (remoteMessage) => {
const handled = await ProsquadSDK.handleNotification(remoteMessage.data);
if (handled) {
await ProsquadSDK.showNotification({
title: remoteMessage.notification?.title ?? 'New Order',
body: remoteMessage.notification?.body ?? '',
data: remoteMessage.data,
});
}
});
// Foreground handler
messaging().onMessage(async (remoteMessage) => {
const handled = await ProsquadSDK.handleNotification(remoteMessage.data);
if (handled) {
await ProsquadSDK.showNotification({
title: remoteMessage.notification?.title ?? 'New Order',
body: remoteMessage.notification?.body ?? '',
data: remoteMessage.data,
});
}
});handleNotification returns true if the notification belongs to Prosquad (whitelisted types: order_assigned, batched_order_assigned, order_available, order_ready_pickup, auto_logout). If it returns false, your app should handle the notification itself.
Query active order status
const status = await ProsquadSDK.getActiveOrderStatus();
if (status) {
console.log(`Active order: ${status.clientId}, state: ${status.orderState}`);
}API Reference
| Function | Returns | Description |
|----------|---------|-------------|
| launch(config, listeners?) | Promise<void> | Opens the full-screen delivery WebView |
| registerDeviceToken(token) | Promise<void> | Registers an FCM token with the Prosquad backend |
| handleNotification(data) | Promise<boolean> | Forwards a push notification to the SDK; returns true if handled |
| showNotification(options) | Promise<void> | Shows a local notification with the Prosquad order alert sound |
| getActiveOrderStatus() | Promise<{clientId, orderState} \| null> | Returns current active order info, or null |
ProsquadLaunchConfig
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| eid | string | Yes | Enterprise ID |
| phoneNumber | string | Yes | Rider's phone number (used for OTP auth) |
| hostUserId | string | Yes | User ID in the host app |
| riderName | string | Yes | Rider's display name |
| city | string | Yes | Rider's city |
ProsquadEventListeners
| Callback | Signature | Description |
|----------|-----------|-------------|
| onOrderComplete | (orderId: string, status: string) => void | Fired when a delivery is completed |
| onClose | () => void | Fired when the rider closes the delivery UI |
| onNotificationReceived | (type: string, data: Record<string, string>) => void | Fired when a Prosquad notification arrives while the UI is closed |
License
MIT
