Giter Site home page Giter Site logo

zagham-nadeem / capacitor-plugin-incoming-call Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 313hemant313/capacitor-plugin-incoming-call

0.0 0.0 0.0 289 KB

capacitor-plugin-incoming-call

JavaScript 2.73% Ruby 5.55% Objective-C 4.26% Java 57.83% TypeScript 10.69% Swift 18.94%

capacitor-plugin-incoming-call's Introduction

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


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

Type Aliases

CallStateChangeListener

(status: PhoneState): void

PhoneStateType

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

capacitor-plugin-incoming-call's People

Contributors

313hemant313 avatar devhus avatar james-infinite-eye avatar zagham-nadeem avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.