Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
react-native-incall-manager
Advanced tools
Handling media-routes/sensors/events during a audio/video chat on React Native
Handling media-routes/sensors/events during a audio/video chat on React Native
The purpose of this module is to handle actions/events during a phone call (audio/video) on react-native
, ex:
basically, it is a telecommunication module which handle most of requirements when making/receiving/talking to a call.
This module is desinged to work with react-native-webrtc you can find demo here: https://github.com/oney/RCTWebRTCDemo
from npm package: npm install react-native-incall-manager
from git package: npm install git://github.com/zxcpoiu/react-native-incall-manager.git
=================================================== ####android:
After install, you can use rnpm
(npm install rnpm -g
) to link android.
use rnpm link react-native-incall-manager
to link or manually if you like.
optional sound files on android if you want to use bundled ringtone/ringback/busytone sound instead of system sound
put files in android/app/src/main/res/raw
and rename file correspond to sound type:
incallmanager_busytone.mp3
incallmanager_ringback.mp3
incallmanager_ringback.mp3
on android, as long as your file extension supported by android, this module will load it.
===================================================
####ios:
since ios part written in swift and it doesn't support static library yet.
before that, you should add this project manually:
Add files in to your project:
add files
to your project and add node_modules/react-native-incall-manager/ios/RNInCallManager/
Copy items if needed
and select Added folders: Create groups
then add it. you will see a new directory named RNInCallmanager under your_project
directory.Setup Objective-C Bridging Header:
project's xcodeproject root
, go to build setting
and search Objective-C Bridging Header
ReactNativeProjectRoot/ios/
, in this case, you should set ../node_modules/react-native-incall-manager/ios/RNInCallManager/RNInCallManager-Bridging-Header.h
optional sound files on android if you want to use bundled ringtone/ringback/busytone sound instead of system sound
copy file if needed
incallmanager_busytone.mp3
incallmanager_ringback.mp3
incallmanager_ringback.mp3
on ios, we only support mp3 files currently.
This module implement a basic handle logic automatically, just:
import InCallManager from 'react-native-incall-manager';
// --- start manager when the chat start based on logics of your app
// On Call Established:
InCallManager.start({media: 'audio'}); // audio/video, default: audio
// ... it will also register and emit events ...
// --- On Call Hangup:
InCallManager.stop();
// ... it will also remote event listeners ...
if you want to use ringback:
// ringback is basically for OUTGOING call. and is part of start().
InCallManager.start({media: 'audio', ringback: '_BUNDLE_'}); // or _DEFAULT_ or _DTMF_
//when callee answered, you MUST stop ringback explicitly:
InCallManager.stopRingback();
if you want to use busytone:
// busytone is basically for OUTGOING call. and is part of stop()
// If the call failed or callee are busing,
// you may want to stop the call and play busytone
InCallManager.stop({busytone: '_DTMF_'}); // or _BUNDLE_ or _DEFAULT_
if you want to use ringtone:
// ringtone is basically for INCOMING call. it's independent to start() and stop()
// if you receiving an incoming call, before user pick up,
// you may want to play ringtone to notify user.
InCallManager.startRingtone('_BUNDLE_'); // or _DEFAULT_ or system filename with extension
// when user pickup
InCallManager.stopRingtone();
InCallManager.start();
// or user hangup
InCallManager.stopRingtone();
InCallManager.stop();
also can interact with events if you want: see API section.
import { DeviceEventEmitter } from 'react-native';
DeviceEventEmitter.addListener('Proximity', function (data) {
// --- do something with events
});
on start:
audio
, route voice to earpiece, otherwise route to speaker.on stop:
you can custom behavior use API/events exposed by this module. see API
section.
note: ios only supports auto
currently.
Methods
Method | android | ios | description |
---|---|---|---|
start({media: ?string, auto: ?boolean, ringback: ?string} ) | :smile: | :smile: | start incall manager. ringback accept non-empty string or it won't play default: {media:'audio', auto: true, ringback: ''} |
stop({busytone: ?string} ) | :smile: | :smile: | stop incall manager busytone accept non-empty string or it won't play default: {busytone: ''} |
turnScreenOn() | :smile: | :rage: | force turn screen on |
turnScreenOff() | :smile: | :rage: | force turn screen off |
setKeepScreenOn(enable: ?boolean ) | :smile: | :smile: | set KeepScreenOn flag = true or false default: false |
setSpeakerphoneOn(enable: ?boolean ) | :smile: | :rage: | toggle speaker ON/OFF once. but not force default: false |
setForceSpeakerphoneOn(flag: ?boolean ) | :smile: | :smile: | true -> force speaker on false -> force speaker off null -> use default behavior according to media type default: null |
setMicrophoneMute(enable: ?boolean ) | :smile: | :rage: | mute/unmute micophone default: false |
Events
Event | android | ios | description |
---|---|---|---|
'Proximity' | :smile: | :smile: | proximity sensor detected changes. data: {'isNear': boolean} |
'WiredHeadset' | :smile: | :rage: | fire when wired headset plug/unplug data: {'isPlugged': boolean, 'hasMic': boolean, 'deviceName': string } |
'NoisyAudio' | :smile: | :rage: | see andriod doc. data: null |
'MediaButton' | :smile: | :rage: | when external device controler pressed button. see android doc data: {'eventText': string, 'eventCode': number } |
'onAudioFocusChange' | :smile: | :rage: | see andriod doc data: {'eventText': string, 'eventCode': number } |
NOTE: platform OS always has the final decision, so some toggle api may not work in some case be care when customize your own behavior
ICS License ( functionality equivalent to MIT License )
I'm not expert neither on ios nor android, any suggestions, pull request, corrections are really appreciated and welcome.
FAQs
Handling media-routes/sensors/events during a audio/video chat on React Native
The npm package react-native-incall-manager receives a total of 5,968 weekly downloads. As such, react-native-incall-manager popularity was classified as popular.
We found that react-native-incall-manager demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.