@techgenzi/services
v1.5.1
Published
Multi-service private React Native library for TechGenzi internal services
Maintainers
Readme
@techgenzi/services
Multi-service native Android & iOS library for React Native applications — Call Logs, SIM Information, Location Services, Notification Management, and Background Tracking.
📦 Services Overview
| Module | Native Class (Android / iOS) | Primary JS Exports | Description |
|---|---|---|---|
| 📱 Phone Call | RNImmediatePhoneCall / TechGenziCall | makePhoneCall(number, options), immediatePhoneCall(number), openDialer(number) | Direct instant phone calling with permission check & dialer fallback |
| 📞 Call Log | CallLogModule / TechGenziCallLog | loadAllCallLogs(), loadCallLogs(limit), loadCallLogsWithFilter(limit, filter) | Call logs with dual-SIM numbers (myNumber, myNumber2). (Android full support; iOS returns [] safely due to Apple sandbox) |
| 💳 SIM | SimManagerModule / TechGenziSimManager | getPhoneNumbers(), getSimCards(), getPhoneNumber() | Multi-strategy single & dual-SIM carrier & slot detection |
| 📍 Location | LocationModule / TechGenziLocationModule | getCurrentLocation() | High-accuracy GPS + reverse Geocoder |
| 🔔 Notification | NotificationModule / TechGenziNotificationModule | showAlert(), showProgress(), cancelNotification() | Local alert & progress notification management |
| 🔄 Background | BackgroundDataModule / TechGenziBackgroundModule | startBackgroundService(), stopBackgroundService() | Continuous GPS tracking loop with HTTP POST sync |
🚀 Installation
1. Install via npm
npm install @techgenzi/servicesOr using yarn:
yarn add @techgenzi/services2. iOS CocoaPods Setup
For iOS, install the CocoaPods dependencies:
cd ios && pod install && cd ..⚙️ Linking Configuration
Option A: Auto-linking (React Native ≥ 0.60) — Recommended
This package supports React Native Auto-linking on both Android and iOS.
After installing the package (npm install @techgenzi/services) and running pod install for iOS, no manual native code changes are required!
# For Android
npx react-native run-android
# For iOS
npx react-native run-iosOption B: Manual Linking (React Native < 0.60 or Custom Setups)
If your project does not use auto-linking, follow these 3 steps:
1. android/settings.gradle
include ':techgenzi-services'
project(':techgenzi-services').projectDir = new File(rootProject.projectDir, '../node_modules/@techgenzi/services/android')2. android/app/build.gradle
dependencies {
implementation project(':techgenzi-services')
}3. Register Package in MainApplication.kt (or .java)
Kotlin (MainApplication.kt):
import com.techgenzi.services.TechGenziPackage
override fun getPackages(): List<ReactPackage> =
PackageList(this).packages.apply {
add(TechGenziPackage())
}Java (MainApplication.java):
import com.techgenzi.services.TechGenziPackage;
@Override
protected List<ReactPackage> getPackages() {
List<ReactPackage> packages = new PackageList(this).getPackages();
packages.add(new TechGenziPackage());
return packages;
}🛡️ Runtime Permissions
Before calling the native modules, request the required permissions in your React Native app:
import { PermissionsAndroid, Platform } from 'react-native';
export const requestAppPermissions = async () => {
if (Platform.OS !== 'android') return true;
const permissions = [
PermissionsAndroid.PERMISSIONS.CALL_PHONE,
PermissionsAndroid.PERMISSIONS.READ_CALL_LOG,
PermissionsAndroid.PERMISSIONS.READ_PHONE_NUMBERS,
PermissionsAndroid.PERMISSIONS.READ_PHONE_STATE,
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION,
];
if (Platform.Version >= 33) {
permissions.push('android.permission.POST_NOTIFICATIONS' as any);
}
const result = await PermissionsAndroid.requestMultiple(permissions);
return Object.values(result).every(
(status) => status === PermissionsAndroid.RESULTS.GRANTED
);
};📖 Part-by-Part Guide & JSON Outputs
1. 📱 Phone Call Service
Provides immediate direct calling without opening the phone dialer, permission handling, and graceful fallback to system dialer (tel:).
Usage:
import {
makePhoneCall,
openDialer,
immediatePhoneCall,
requestCallPermission,
checkCallPermission
} from '@techgenzi/services';
// 1. Direct Call with automatic permission request & dialer fallback
const success = await makePhoneCall('+919876543210');
// 2. Direct Call strictly without opening dialer
await makePhoneCall('+919876543210', { fallbackToDialer: false });
// 3. Open system dialer only (no direct calling)
await openDialer('+919876543210');
// 4. Raw Immediate Call
immediatePhoneCall('+919876543210');2. 📞 Call Log Service
Fetches device call logs along with caller number (phoneNumber) and device SIM number (myNumber & myNumber2 for dual-SIM).
Usage:
import {
loadAllCallLogs,
loadCallLogs,
loadCallLogsWithFilter
} from '@techgenzi/services';
// Fetch all call logs
const allLogs = await loadAllCallLogs();
// Fetch latest 20 call logs
const recentLogs = await loadCallLogs(20);
// Filter by phone number substring
const filteredLogs = await loadCallLogsWithFilter(10, '98765');JSON Output:
[
{
"phoneNumber": "9876543210",
"myNumber": "9123456780",
"myNumber2": "9123456781",
"myCarrier": "Jio",
"mySimName": "SIM 1",
"type": "OUTGOING",
"rawType": 2,
"duration": 65,
"dateTime": "1724237123000",
"timestamp": "1724237123000",
"name": "John Doe",
"photoUri": "content://com.android.contacts/contacts/123/photo",
"geocodedLocation": "Chennai, Tamil Nadu",
"isRead": 1,
"features": 0,
"simId": "899186..."
},
{
"phoneNumber": "9112233445",
"myNumber": "9123456781",
"myNumber2": null,
"myCarrier": "Airtel",
"mySimName": "SIM 2",
"type": "INCOMING",
"rawType": 1,
"duration": 120,
"dateTime": "1724236500000",
"timestamp": "1724236500000",
"name": "Jane Smith",
"photoUri": null,
"geocodedLocation": "Coimbatore, Tamil Nadu",
"isRead": 1,
"features": 0,
"simId": "899187..."
}
]3. 💳 SIM Service
Detects single & dual-SIM details, phone numbers, and carrier information using multi-level fallback strategies (Android 13+ SubscriptionManager → Legacy SubscriptionInfo → TelephonyManager Line 1).
Methods:
A. Dual-SIM Phone Numbers (getPhoneNumbers)
import { getPhoneNumbers } from '@techgenzi/services';
const simNumbers = await getPhoneNumbers();
console.log('SIM Numbers:', simNumbers);JSON Output:
{
"myNumber": "9123456780",
"myNumber2": "9123456781",
"numbers": [
"9123456780",
"9123456781"
],
"simCount": 2
}(If single-SIM device, myNumber2 will be null and simCount will be 1)
B. Full SIM Cards Info (getSimCards)
import { getSimCards } from '@techgenzi/services';
const simCards = await getSimCards();
console.log('SIM Cards:', simCards);JSON Output:
[
{
"simSlotIndex": 0,
"subscriptionId": 1,
"phoneNumber": "9123456780",
"carrierName": "Jio",
"displayName": "SIM 1",
"countryIso": "in",
"iccId": "8991860000000000000",
"isDataRoaming": false
},
{
"simSlotIndex": 1,
"subscriptionId": 2,
"phoneNumber": "9123456781",
"carrierName": "Airtel",
"displayName": "SIM 2",
"countryIso": "in",
"iccId": "8991870000000000000",
"isDataRoaming": false
}
]C. Primary SIM Phone Number (getPhoneNumber)
import { getPhoneNumber } from '@techgenzi/services';
const primaryNumber = await getPhoneNumber(); // "9123456780" | null4. 📍 Location Service
One-shot high-accuracy geolocation fetch combining Google Play Fused Location Provider and Android native Geocoder for human-readable addresses. Fully compatible with react-native-get-location.
Usage:
import { getCurrentLocation, getCurrentPosition } from '@techgenzi/services';
// Simple call with default options
const location = await getCurrentLocation();
// With custom options (enableHighAccuracy, timeout in ms)
const detailedLocation = await getCurrentLocation({
enableHighAccuracy: true,
timeout: 15000,
});
// react-native-get-location compatible alias:
const pos = await getCurrentPosition({
enableHighAccuracy: true,
timeout: 15000,
});Options:
| Option | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| enableHighAccuracy | boolean | true | When true, requests GPS high-accuracy fix; when false, uses balanced battery / network provider. |
| timeout | number | 15000 | Maximum wait duration in milliseconds before fallback. |
JSON Output:
{
"latitude": 13.0826802,
"longitude": 80.2707184,
"altitude": 14.5,
"accuracy": 8.2,
"speed": 0.0,
"bearing": 0.0,
"time": 1726038745000,
"provider": "fused",
"address": "Poonamallee High Rd, Park Town, Chennai, Tamil Nadu 600003, India"
}5. 🔔 Notification Service
Create and manage Android system notification channels and send native alerts, progress bars, and silent notifications.
Usage:
import {
createNotificationChannels,
showAlert,
showProgress,
cancelNotification
} from '@techgenzi/services';
// 1. Initialize notification channels once during app start
await createNotificationChannels();
// 2. Show alert notification
await showAlert(1001, "Sync Complete", "All records synced successfully.");
// 3. Show progress notification
await showProgress(1002, "Uploading Files", 45, 100);
// 4. Cancel a notification
await cancelNotification(1001);Available Channels:
techgenzi_alerts— High priority alerts with sound/vibrationtechgenzi_location— Location tracking notificationstechgenzi_silent— Low priority background updatestechgenzi_fg— Foreground service persistent notifications
6. 🔄 Background Tracking Service
Launches a foreground service that runs a 15-second loop fetching GPS coordinates and transmitting an HTTP POST payload to your analytics/tracking backend.
Usage:
import {
startBackgroundService,
stopBackgroundService
} from '@techgenzi/services';
// Start 15-second tracking loop
await startBackgroundService({
phno: "9123456780",
lat: "13.0826802",
long: "80.2707184",
add: "Chennai, Tamil Nadu",
apiEndpoint: "https://your-api-domain.com/api/location/track" // Optional custom URL
});
// Stop tracking when user clocks out
await stopBackgroundService();JSON Payload Transmitted via HTTP POST:
{
"phno": "9123456780",
"lat": "13.0826802",
"long": "80.2707184",
"add": "Chennai, Tamil Nadu"
}🛠️ TypeScript Types
export interface CallLogEntry {
phoneNumber: string;
myNumber: string;
myNumber2: string | null;
myCarrier: string;
mySimName: string;
type: 'INCOMING' | 'OUTGOING' | 'MISSED' | 'VOICEMAIL' | 'REJECTED' | 'BLOCKED' | 'ANSWERED_EXTERNALLY' | 'UNKNOWN';
rawType: number;
duration: number;
dateTime: string;
timestamp: string;
name?: string;
photoUri?: string;
geocodedLocation?: string;
isRead?: number;
features?: number;
simId?: string;
}
export interface LocationResult {
latitude: number;
longitude: number;
address: string;
}
export interface TrackerPayload {
phno: string;
lat: string;
long: string;
add: string;
apiEndpoint?: string;
}📄 License
UNLICENSED © TechGenzi
