npm.io
0.1.2 • Published 6 months ago

@gyo-framework/phone-caller

Licence
MIT
Version
0.1.2
Deps
0
Size
10 kB
Vulns
0
Weekly
0
DeprecatedThis package is deprecated

@gyo-framework/phone-caller

Gyo plugin for making phone calls via Android Intent.

Installation

npm install @gyo-framework/phone-caller

Usage

import { PhoneCaller } from '@gyo-framework/phone-caller';

const caller = new PhoneCaller();

// Make a phone call
const called = await caller.call({ phoneNumber: '01012345678' });

// Get call log
const { entries, count } = await caller.getCallLog({ limit: 10 });

// Check availability
if (caller.isAvailable()) {
  // running in WebView with native bridge
}

// Cleanup
caller.destroy();

API

PhoneCaller
Method Returns Description
call(params) Promise<boolean> Make a phone call
getCallLog(params) Promise<CallLogResult> Get recent call log entries
isAvailable() boolean Check if native bridge is available
destroy() void Clean up resources
Types
interface CallParams {
  phoneNumber: string;
}

interface GetCallLogParams {
  limit: number;
}

interface CallLogEntry {
  number: string;
  name: string;
  date: number;
  duration: number;
  type: string;
}

interface CallLogResult {
  entries: CallLogEntry[];
  count: number;
}

Android Setup

Register the bridge handler in your MainActivity.kt:

import gyo.plugins.phone_caller.PhoneCallerBridge
import gyo.plugins.bridge.BridgeRegistry

// In onCreate():
BridgeRegistry.register("phone_caller", PhoneCallerBridge(this))
Permissions

Add to AndroidManifest.xml:

<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />

Peer Dependencies

  • @gyo-framework/bridge@^0.1.3

License

MIT

Keywords