capacitor-plugin-phone-well

PhoneWell is capacitor plugin for utilizing phone calls.

Install

npm install capacitor-plugin-phone-well
npx cap sync

Add the required permissions to the Android source code

android\app\src\main\java\app\[package_namespace]\MainActivity.java

import android.os.Bundle; // required for onCreate parameter
import androidx.core.app.ActivityCompat;
import com.getcapacitor.BridgeActivity;

public class MainActivity extends BridgeActivity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String[] PERMISSIONS = {
      android.Manifest.permission.READ_PHONE_STATE,
      android.Manifest.permission.READ_CALL_LOG,
      android.Manifest.permission.PROCESS_OUTGOING_CALLS,
    };

    ActivityCompat.requestPermissions(MainActivity.this, PERMISSIONS, 0);
  }
}

Usage

Typescipt side changes:

console.log('### Test PhoneWell plugin ###');
PhoneWell.detectCallState({ action: 'ACTIVATE' })
  .then(x => console.log(x))
  .catch(e => console.error(e));
PhoneWell.addListener('callStateChange', res => {
  console.log('### Listening to callStateChange ###');
  console.log(res);
});

PhoneWell.start({ phone: '+905555555' });

API

echo(...)

echo(options: { value: string; }) => Promise<{ value: string; }>
Param Type
options { value: string; }

Returns: Promise<{ value: string; }>


detectCallState(...)

detectCallState(options: { action: string; }) => Promise<{ action: string; }>

To enable / disable detection of calls options: { action: 'ACTIVATE' | 'DEACTIVATE' }

Param Type
options { action: string; }

Returns: Promise<{ action: string; }>


addListener('callStateChange', ...)

addListener(eventName: 'callStateChange', listenerFunc: CallStateChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle
Param Type
eventName 'callStateChange'
listenerFunc CallStateChangeListener

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


start(...)

start(options: PhoneCallOptions) => Promise<SucessCallBack>
Param Type
options PhoneCallOptions

Returns: Promise<SucessCallBack>


Interfaces

PluginListenerHandle

Prop Type
remove () => Promise<void>

PhoneState

Prop Type Description Since
callActive boolean Whether there is an active call or not. 1.0.0
callState PhoneStateType The type of call. 'RINGING' | 'OUTGOING' | 'IDLE' | 'ON_CALL' | 'ON_HOLD' 1.0.0
incomingNumber string
outgoingNumber string

SucessCallBack

Prop Type
msg string

PhoneCallOptions

Prop Type
phone string

Type Aliases

CallStateChangeListener

(status: PhoneState): void

PhoneStateType

'RINGING' | 'OUTGOING' | 'IDLE' | 'ON_CALL' | 'ON_HOLD'