0.1.0 • Published 12 months ago

capacitor-plugin-incoming-call v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

capacitor-plugin-incoming-call

capacitor-plugin-incoming-call

Install

install the package and sync the project.

npm install capacitor-plugin-incoming-call
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 com.getcapacitor.BridgeActivity;
import androidx.core.app.ActivityCompat;

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
    };

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

}

Usage

Typescipt side changes:

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

API

echo(...)

echo(options: { value: string; }) => Promise<{ value: string; }>
ParamType
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' }

ParamType
options{ action: string; }

Returns: Promise<{ action: string; }>


addListener('callStateChange', ...)

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

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


Interfaces

PluginListenerHandle

PropType
remove() => Promise<void>

PhoneState

PropTypeDescriptionSince
callActivebooleanWhether there is an active call or not.1.0.0
callStatePhoneStateTypeThe type of call. 'RINGING' | 'OUTGOING' | 'IDLE' | 'ON_CALL' | 'ON_HOLD'1.0.0
incomingNumberstring
outgoingNumberstring

Type Aliases

CallStateChangeListener

(status: PhoneState): void

PhoneStateType

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

0.1.0

12 months ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.3

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago