PhoneWell is capacitor plugin for utilizing phone calls.
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);
}
}
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' });
echo(...)
detectCallState(...)
addListener('callStateChange', ...)
start(...)
- Interfaces
- Type Aliases
echo(options: { value: string; }) => Promise<{ value: string; }>
Param | Type |
---|---|
options |
{ value: string; } |
Returns: Promise<{ value: string; }>
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(eventName: 'callStateChange', listenerFunc: CallStateChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle
Param | Type |
---|---|
eventName |
'callStateChange' |
listenerFunc |
CallStateChangeListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
start(options: PhoneCallOptions) => Promise<SucessCallBack>
Param | Type |
---|---|
options |
PhoneCallOptions |
Returns: Promise<SucessCallBack>
Prop | Type |
---|---|
remove |
() => Promise<void> |
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 |
Prop | Type |
---|---|
msg |
string |
Prop | Type |
---|---|
phone |
string |
(status: PhoneState): void
'RINGING' | 'OUTGOING' | 'IDLE' | 'ON_CALL' | 'ON_HOLD'