voice-react-native-sdk 1.6.2-fork.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +206 -0
- package/README.md +179 -0
- package/android/build.gradle +113 -0
- package/android/gradle.properties +29 -0
- package/android/src/main/AndroidManifest.xml +30 -0
- package/android/src/main/java/com/twiliovoicereactnative/AudioSwitchManager.java +141 -0
- package/android/src/main/java/com/twiliovoicereactnative/CallListenerProxy.java +186 -0
- package/android/src/main/java/com/twiliovoicereactnative/CallMessageListenerProxy.java +103 -0
- package/android/src/main/java/com/twiliovoicereactnative/CallRecordDatabase.java +183 -0
- package/android/src/main/java/com/twiliovoicereactnative/CommonConstants.java +195 -0
- package/android/src/main/java/com/twiliovoicereactnative/ConfigurationProperties.java +41 -0
- package/android/src/main/java/com/twiliovoicereactnative/Constants.java +23 -0
- package/android/src/main/java/com/twiliovoicereactnative/ExpoActivityLifecycleListener.java +27 -0
- package/android/src/main/java/com/twiliovoicereactnative/ExpoApplicationLifecycleListener.java +14 -0
- package/android/src/main/java/com/twiliovoicereactnative/ExpoModule.kt +36 -0
- package/android/src/main/java/com/twiliovoicereactnative/ExpoPackage.java +20 -0
- package/android/src/main/java/com/twiliovoicereactnative/JSEventEmitter.java +98 -0
- package/android/src/main/java/com/twiliovoicereactnative/MediaPlayerManager.java +58 -0
- package/android/src/main/java/com/twiliovoicereactnative/NotificationUtility.java +363 -0
- package/android/src/main/java/com/twiliovoicereactnative/ReactNativeArgumentsSerializer.java +276 -0
- package/android/src/main/java/com/twiliovoicereactnative/SDKLog.java +74 -0
- package/android/src/main/java/com/twiliovoicereactnative/StatsListenerProxy.java +178 -0
- package/android/src/main/java/com/twiliovoicereactnative/TwilioVoiceReactNativeModule.java +778 -0
- package/android/src/main/java/com/twiliovoicereactnative/TwilioVoiceReactNativePackage.java +28 -0
- package/android/src/main/java/com/twiliovoicereactnative/VoiceActivityProxy.java +101 -0
- package/android/src/main/java/com/twiliovoicereactnative/VoiceApplicationProxy.java +133 -0
- package/android/src/main/java/com/twiliovoicereactnative/VoiceFirebaseMessagingService.java +88 -0
- package/android/src/main/java/com/twiliovoicereactnative/VoiceService.java +403 -0
- package/android/src/main/res/drawable/answered_call_small_icon.png +0 -0
- package/android/src/main/res/drawable/ic_launcher_round.png +0 -0
- package/android/src/main/res/drawable/ic_launcher_sdk.png +0 -0
- package/android/src/main/res/drawable/incoming_call_small_icon.png +0 -0
- package/android/src/main/res/drawable/outgoing_call_small_icon.png +0 -0
- package/android/src/main/res/raw/disconnect.wav +0 -0
- package/android/src/main/res/raw/incoming.wav +0 -0
- package/android/src/main/res/raw/outgoing.wav +0 -0
- package/android/src/main/res/raw/ringtone.wav +0 -0
- package/android/src/main/res/raw/silent.wav +0 -0
- package/android/src/main/res/values/colors.xml +11 -0
- package/android/src/main/res/values/config.xml +5 -0
- package/android/src/main/res/values/dimens.xml +7 -0
- package/android/src/main/res/values/strings.xml +25 -0
- package/android/src/main/res/values/styles.xml +10 -0
- package/android/src/main/res/values-night/colors.xml +11 -0
- package/expo-config-plugin/android.js +191 -0
- package/expo-config-plugin/ios.js +22 -0
- package/expo-module.config.json +6 -0
- package/ios/TwilioVoicePushRegistry.h +19 -0
- package/ios/TwilioVoicePushRegistry.m +72 -0
- package/ios/TwilioVoiceReactNative+CallInvite.m +56 -0
- package/ios/TwilioVoiceReactNative+CallKit.m +533 -0
- package/ios/TwilioVoiceReactNative+CallMessage.m +81 -0
- package/ios/TwilioVoiceReactNative.h +74 -0
- package/ios/TwilioVoiceReactNative.m +1046 -0
- package/ios/TwilioVoiceReactNative.xcodeproj/project.pbxproj +328 -0
- package/ios/TwilioVoiceReactNativeConstants.h +200 -0
- package/ios/Utilities/TwilioVoiceStatsReport.h +175 -0
- package/lib/commonjs/AudioDevice.js +101 -0
- package/lib/commonjs/AudioDevice.js.map +1 -0
- package/lib/commonjs/Call.js +765 -0
- package/lib/commonjs/Call.js.map +1 -0
- package/lib/commonjs/CallInvite.js +452 -0
- package/lib/commonjs/CallInvite.js.map +1 -0
- package/lib/commonjs/CallMessage/CallMessage.js +54 -0
- package/lib/commonjs/CallMessage/CallMessage.js.map +1 -0
- package/lib/commonjs/CallMessage/IncomingCallMessage.js +120 -0
- package/lib/commonjs/CallMessage/IncomingCallMessage.js.map +1 -0
- package/lib/commonjs/CallMessage/OutgoingCallMessage.js +148 -0
- package/lib/commonjs/CallMessage/OutgoingCallMessage.js.map +1 -0
- package/lib/commonjs/ExpoModule.js +69 -0
- package/lib/commonjs/ExpoModule.js.map +1 -0
- package/lib/commonjs/Voice.js +611 -0
- package/lib/commonjs/Voice.js.map +1 -0
- package/lib/commonjs/common.js +26 -0
- package/lib/commonjs/common.js.map +1 -0
- package/lib/commonjs/constants.js +158 -0
- package/lib/commonjs/constants.js.map +1 -0
- package/lib/commonjs/error/InvalidArgumentError.js +32 -0
- package/lib/commonjs/error/InvalidArgumentError.js.map +1 -0
- package/lib/commonjs/error/InvalidStateError.js +33 -0
- package/lib/commonjs/error/InvalidStateError.js.map +1 -0
- package/lib/commonjs/error/TwilioError.js +38 -0
- package/lib/commonjs/error/TwilioError.js.map +1 -0
- package/lib/commonjs/error/UnsupportedPlatformError.js +33 -0
- package/lib/commonjs/error/UnsupportedPlatformError.js.map +1 -0
- package/lib/commonjs/error/generated.js +2343 -0
- package/lib/commonjs/error/generated.js.map +1 -0
- package/lib/commonjs/error/index.js +112 -0
- package/lib/commonjs/error/index.js.map +1 -0
- package/lib/commonjs/error/utility.js +37 -0
- package/lib/commonjs/error/utility.js.map +1 -0
- package/lib/commonjs/index.js +95 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/type/AudioDevice.js +6 -0
- package/lib/commonjs/type/AudioDevice.js.map +1 -0
- package/lib/commonjs/type/Call.js +6 -0
- package/lib/commonjs/type/Call.js.map +1 -0
- package/lib/commonjs/type/CallInvite.js +6 -0
- package/lib/commonjs/type/CallInvite.js.map +1 -0
- package/lib/commonjs/type/CallKit.js +30 -0
- package/lib/commonjs/type/CallKit.js.map +1 -0
- package/lib/commonjs/type/CallMessage.js +6 -0
- package/lib/commonjs/type/CallMessage.js.map +1 -0
- package/lib/commonjs/type/Error.js +6 -0
- package/lib/commonjs/type/Error.js.map +1 -0
- package/lib/commonjs/type/NativeModule.js +6 -0
- package/lib/commonjs/type/NativeModule.js.map +1 -0
- package/lib/commonjs/type/RTCStats.js +29 -0
- package/lib/commonjs/type/RTCStats.js.map +1 -0
- package/lib/commonjs/type/Voice.js +6 -0
- package/lib/commonjs/type/Voice.js.map +1 -0
- package/lib/commonjs/type/common.js +2 -0
- package/lib/commonjs/type/common.js.map +1 -0
- package/lib/module/AudioDevice.js +97 -0
- package/lib/module/AudioDevice.js.map +1 -0
- package/lib/module/Call.js +766 -0
- package/lib/module/Call.js.map +1 -0
- package/lib/module/CallInvite.js +450 -0
- package/lib/module/CallInvite.js.map +1 -0
- package/lib/module/CallMessage/CallMessage.js +51 -0
- package/lib/module/CallMessage/CallMessage.js.map +1 -0
- package/lib/module/CallMessage/IncomingCallMessage.js +116 -0
- package/lib/module/CallMessage/IncomingCallMessage.js.map +1 -0
- package/lib/module/CallMessage/OutgoingCallMessage.js +154 -0
- package/lib/module/CallMessage/OutgoingCallMessage.js.map +1 -0
- package/lib/module/ExpoModule.js +58 -0
- package/lib/module/ExpoModule.js.map +1 -0
- package/lib/module/Voice.js +598 -0
- package/lib/module/Voice.js.map +1 -0
- package/lib/module/common.js +11 -0
- package/lib/module/common.js.map +1 -0
- package/lib/module/constants.js +151 -0
- package/lib/module/constants.js.map +1 -0
- package/lib/module/error/InvalidArgumentError.js +23 -0
- package/lib/module/error/InvalidArgumentError.js.map +1 -0
- package/lib/module/error/InvalidStateError.js +24 -0
- package/lib/module/error/InvalidStateError.js.map +1 -0
- package/lib/module/error/TwilioError.js +29 -0
- package/lib/module/error/TwilioError.js.map +1 -0
- package/lib/module/error/UnsupportedPlatformError.js +24 -0
- package/lib/module/error/UnsupportedPlatformError.js.map +1 -0
- package/lib/module/error/generated.js +2315 -0
- package/lib/module/error/generated.js.map +1 -0
- package/lib/module/error/index.js +6 -0
- package/lib/module/error/index.js.map +1 -0
- package/lib/module/error/utility.js +27 -0
- package/lib/module/error/utility.js.map +1 -0
- package/lib/module/index.js +23 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/type/AudioDevice.js +2 -0
- package/lib/module/type/AudioDevice.js.map +1 -0
- package/lib/module/type/Call.js +2 -0
- package/lib/module/type/Call.js.map +1 -0
- package/lib/module/type/CallInvite.js +2 -0
- package/lib/module/type/CallInvite.js.map +1 -0
- package/lib/module/type/CallKit.js +22 -0
- package/lib/module/type/CallKit.js.map +1 -0
- package/lib/module/type/CallMessage.js +2 -0
- package/lib/module/type/CallMessage.js.map +1 -0
- package/lib/module/type/Error.js +2 -0
- package/lib/module/type/Error.js.map +1 -0
- package/lib/module/type/NativeModule.js +2 -0
- package/lib/module/type/NativeModule.js.map +1 -0
- package/lib/module/type/RTCStats.js +21 -0
- package/lib/module/type/RTCStats.js.map +1 -0
- package/lib/module/type/Voice.js +2 -0
- package/lib/module/type/Voice.js.map +1 -0
- package/lib/module/type/common.js +2 -0
- package/lib/module/type/common.js.map +1 -0
- package/lib/typescript/AudioDevice.d.ts +74 -0
- package/lib/typescript/Call.d.ts +874 -0
- package/lib/typescript/CallInvite.d.ts +484 -0
- package/lib/typescript/CallMessage/CallMessage.d.ts +53 -0
- package/lib/typescript/CallMessage/IncomingCallMessage.d.ts +75 -0
- package/lib/typescript/CallMessage/OutgoingCallMessage.d.ts +198 -0
- package/lib/typescript/ExpoModule.d.ts +13 -0
- package/lib/typescript/Voice.d.ts +620 -0
- package/lib/typescript/common.d.ts +11 -0
- package/lib/typescript/constants.d.ts +148 -0
- package/lib/typescript/error/InvalidArgumentError.d.ts +11 -0
- package/lib/typescript/error/InvalidStateError.d.ts +12 -0
- package/lib/typescript/error/TwilioError.d.ts +14 -0
- package/lib/typescript/error/UnsupportedPlatformError.d.ts +12 -0
- package/lib/typescript/error/generated.d.ts +1558 -0
- package/lib/typescript/error/index.d.ts +5 -0
- package/lib/typescript/error/utility.d.ts +12 -0
- package/lib/typescript/index.d.ts +18 -0
- package/lib/typescript/type/AudioDevice.d.ts +15 -0
- package/lib/typescript/type/Call.d.ts +59 -0
- package/lib/typescript/type/CallInvite.d.ts +40 -0
- package/lib/typescript/type/CallKit.d.ts +60 -0
- package/lib/typescript/type/CallMessage.d.ts +20 -0
- package/lib/typescript/type/Error.d.ts +9 -0
- package/lib/typescript/type/NativeModule.d.ts +59 -0
- package/lib/typescript/type/RTCStats.d.ts +91 -0
- package/lib/typescript/type/Voice.d.ts +16 -0
- package/lib/typescript/type/common.d.ts +15 -0
- package/package.json +167 -0
- package/src/AudioDevice.tsx +88 -0
- package/src/Call.tsx +1343 -0
- package/src/CallInvite.tsx +757 -0
- package/src/CallMessage/CallMessage.ts +83 -0
- package/src/CallMessage/IncomingCallMessage.ts +104 -0
- package/src/CallMessage/OutgoingCallMessage.ts +308 -0
- package/src/ExpoModule.ts +59 -0
- package/src/Voice.tsx +1010 -0
- package/src/common.ts +16 -0
- package/src/constants.ts +193 -0
- package/src/error/InvalidArgumentError.ts +19 -0
- package/src/error/InvalidStateError.ts +19 -0
- package/src/error/TwilioError.ts +22 -0
- package/src/error/UnsupportedPlatformError.ts +19 -0
- package/src/error/generated.ts +2277 -0
- package/src/error/index.ts +18 -0
- package/src/error/utility.ts +36 -0
- package/src/index.tsx +24 -0
- package/src/type/AudioDevice.ts +18 -0
- package/src/type/Call.ts +102 -0
- package/src/type/CallInvite.ts +59 -0
- package/src/type/CallKit.ts +61 -0
- package/src/type/CallMessage.ts +31 -0
- package/src/type/Error.ts +11 -0
- package/src/type/NativeModule.ts +93 -0
- package/src/type/RTCStats.ts +99 -0
- package/src/type/Voice.ts +31 -0
- package/src/type/common.ts +16 -0
- package/twilio-voice-react-native.podspec +22 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["Call.tsx"],"names":["Call","EventEmitter","constructor","uuid","customParameters","from","sid","state","to","isMuted","isOnHold","initialConnectedTimestamp","nativeCallEvent","type","call","callInfo","handler","_nativeEventHandler","Error","_uuid","Constants","CallEventConnected","_update","emit","Event","Connected","CallEventConnectFailure","message","code","error","ConnectFailure","CallEventDisconnected","Disconnected","CallEventReconnecting","Reconnecting","CallEventReconnected","Reconnected","CallEventRinging","Ringing","CallEventQualityWarningsChanged","currentWarnings","CallEventCurrentWarnings","previousWarnings","CallEventPreviousWarnings","QualityWarningsChanged","CallEventMessageReceived","callMessage","callMessageInfo","incomingCallMessage","IncomingCallMessage","MessageReceived","_customParameters","_from","_sid","_state","State","Connecting","_to","_isMuted","_isOnHold","_initialConnectedTimestamp","Date","undefined","_handleConnectedEvent","_handleConnectFailureEvent","_handleDisconnectedEvent","_handleReconnectedEvent","_handleReconnectingEvent","_handleRingingEvent","_handleQualityWarningsChangedEvent","_handleMessageReceivedEvent","NativeEventEmitter","addListener","ScopeCall","_handleNativeEvent","newState","eventTypeStateMap","disconnect","NativeModule","call_disconnect","getCustomParameters","getFrom","getInitialConnectedTimestamp","getSid","getState","getStats","call_getStats","getTo","hold","call_hold","mute","call_mute","sendDigits","digits","call_sendDigits","sendMessage","content","contentType","messageType","voiceEventSid","call_sendMessage","outgoingCallMessage","OutgoingCallMessage","postFeedback","score","issue","validScores","includes","InvalidArgumentError","Object","values","Issue","nativeScore","scoreMap","nativeIssue","issueMap","call_postFeedback","CallStateConnected","CallStateConnecting","CallStateDisconnected","CallStateReconnecting","CallStateRinging","QualityWarning","Score","Listener","NotReported","One","Two","Three","Four","Five","CallFeedbackScoreNotReported","CallFeedbackScoreOne","CallFeedbackScoreTwo","CallFeedbackScoreThree","CallFeedbackScoreFour","CallFeedbackScoreFive","AudioLatency","CallFeedbackIssueAudioLatency","ChoppyAudio","CallFeedbackIssueChoppyAudio","DroppedCall","CallFeedbackIssueDroppedCall","Echo","CallFeedbackIssueEcho","NoisyCall","CallFeedbackIssueNoisyCall","CallFeedbackIssueNotReported","OneWayAudio","CallFeedbackIssueOneWayAudio"],"mappings":";;;;;;;AAOA;;AAEA;;AACA;;AAUA;;AACA;;AACA;;AACA;;AACA;;;;AAmTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,IAAN,SAAmBC,0BAAnB,CAAgC;AACrC;AACF;AACA;AACA;AACA;;AAEE;AACF;AACA;;AAEE;AACF;AACA;;AAEE;AACF;AACA;;AAEE;AACF;AACA;;AAEE;AACF;AACA;;AAEE;AACF;AACA;;AAEE;AACF;AACA;AACA;AACA;AACA;;AAEE;AACF;AACA;;AAGE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;AAME;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACEC,EAAAA,WAAW,CAAC;AACVC,IAAAA,IADU;AAEVC,IAAAA,gBAFU;AAGVC,IAAAA,IAHU;AAIVC,IAAAA,GAJU;AAKVC,IAAAA,KALU;AAMVC,IAAAA,EANU;AAOVC,IAAAA,OAPU;AAQVC,IAAAA,QARU;AASVC,IAAAA;AATU,GAAD,EAUQ;AACjB;;AADiB;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,gDAkDWC,eAAD,IAAsC;AACjE,YAAM;AAAEC,QAAAA,IAAF;AAAQC,QAAAA,IAAI,EAAEC;AAAd,UAA2BH,eAAjC;AAEA,YAAMI,OAAO,GAAG,KAAKC,mBAAL,CAAyBJ,IAAzB,CAAhB;;AACA,UAAI,OAAOG,OAAP,KAAmB,WAAvB,EAAoC;AAClC,cAAM,IAAIE,KAAJ,CACH,4DAA2DL,IAAK,IAD7D,CAAN;AAGD;;AAED,UAAIE,QAAQ,CAACZ,IAAT,KAAkB,KAAKgB,KAA3B,EAAkC;AAChCH,QAAAA,OAAO,CAACJ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 2022 Twilio, Inc. All rights reserved. Licensed under the Twilio\n * license.\n *\n * See LICENSE in the project root for license information.\n */\n\nimport { EventEmitter } from 'eventemitter3';\nimport type { RTCStats } from './';\nimport { NativeModule, NativeEventEmitter } from './common';\nimport { Constants } from './constants';\nimport type {\n NativeCallEvent,\n NativeCallEventType,\n NativeCallInfo,\n NativeCallFeedbackIssue,\n NativeCallFeedbackScore,\n} from './type/Call';\nimport type { CustomParameters, Uuid } from './type/common';\nimport type { TwilioError } from './error/TwilioError';\nimport { InvalidArgumentError } from './error/InvalidArgumentError';\nimport { constructTwilioError } from './error/utility';\nimport { CallMessage, validateCallMessage } from './CallMessage/CallMessage';\nimport { IncomingCallMessage } from './CallMessage/IncomingCallMessage';\nimport { OutgoingCallMessage } from './CallMessage/OutgoingCallMessage';\n\n/**\n * Defines strict typings for all events emitted by {@link (Call:class)\n * | Call objects}.\n *\n * @remarks\n * Note that the `on` function is an alias for the `addListener` function.\n * They share identical functionality and either may be used interchangeably.\n *\n * - See also the {@link (Call:class) | Call class}.\n * - See also the {@link (Call:namespace) | Call namespace}.\n *\n * @public\n */\nexport declare interface Call {\n /**\n * ------------\n * Emit Typings\n * ------------\n */\n\n /** @internal */\n emit(connectedEvent: Call.Event.Connected): boolean;\n\n /** @internal */\n emit(\n connectFailureEvent: Call.Event.ConnectFailure,\n error: TwilioError\n ): boolean;\n\n /** @internal */\n emit(reconnectingEvent: Call.Event.Reconnecting, error: TwilioError): boolean;\n\n /** @internal */\n emit(reconnectedEvent: Call.Event.Reconnected): boolean;\n\n /** @internal */\n emit(\n disconnectedEvent: Call.Event.Disconnected,\n error?: TwilioError\n ): boolean;\n\n /** @internal */\n emit(ringingEvent: Call.Event.Ringing): boolean;\n\n /** @internal */\n emit(\n qualityWarningsChangedEvent: Call.Event.QualityWarningsChanged,\n currentQualityWarnings: Call.QualityWarning[],\n previousQualityWarnings: Call.QualityWarning[]\n ): boolean;\n\n /** @internal */\n emit(\n messageReceivedEvent: Call.Event.MessageReceived,\n incomingCallMessage: IncomingCallMessage\n ): boolean;\n\n /**\n * ----------------\n * Listener Typings\n * ----------------\n */\n\n /**\n * Connected event. Raised when the call has successfully connected.\n *\n * @example\n * ```typescript\n * call.addListener(Call.Event.Connected, () => {\n * // call has been connected\n * });\n * ```\n *\n * @param connectedEvent - The raised event string.\n * @param listener - A listener function that will be invoked when the event\n * is raised.\n * @returns - The call object.\n */\n addListener(\n connectedEvent: Call.Event.Connected,\n listener: Call.Listener.Connected\n ): this;\n /**\n * {@inheritDoc (Call:interface).(addListener:1)}\n */\n on(\n connectedEvent: Call.Event.Connected,\n listener: Call.Listener.Connected\n ): this;\n\n /**\n * Connect failure event. Raised when the call has failed to connect.\n *\n * @example\n * ```typescript\n * call.addListener(Call.Event.ConnectFailure, (error) => {\n * // call was unable to connect, handle error\n * });\n * ```\n *\n * @param connectFailureEvent - The raised event string.\n * @param listener - A listener function that will be invoked when the event\n * is raised.\n * @returns - The call object.\n */\n addListener(\n connectFailureEvent: Call.Event.ConnectFailure,\n listener: Call.Listener.ConnectFailure\n ): this;\n /**\n * {@inheritDoc (Call:interface).(addListener:2)}\n */\n on(\n connectFailureEvent: Call.Event.ConnectFailure,\n listener: Call.Listener.ConnectFailure\n ): this;\n\n /**\n * Reconnecting event. Raised when the call is reconnecting.\n *\n * @example\n * ```typescript\n * call.addListener(Call.Event.Reconnecting, (error) => {\n * // call is attempting to reconnect, handle error\n * });\n * ```\n *\n * @param reconnectingEvent - The raised event string.\n * @param listener - A listener function that will be invoked when the event\n * is raised.\n * @returns - The call object.\n */\n addListener(\n reconnectingEvent: Call.Event.Reconnecting,\n listener: Call.Listener.Reconnecting\n ): this;\n /**\n * {@inheritDoc (Call:interface).(addListener:3)}\n */\n on(\n reconnectingEvent: Call.Event.Reconnecting,\n listener: Call.Listener.Reconnecting\n ): this;\n\n /**\n * Reconnected event. Raised when the call has recovered and reconnected.\n *\n * @example\n * ```typescript\n * call.addListener(Call.Event.Reconnected, () => {\n * // call has reconnected\n * });\n * ```\n *\n * @param reconnectedEvent - The raised event string.\n * @param listener - A listener function that will be invoked when the event\n * is raised.\n * @returns - The call object.\n */\n addListener(\n reconnectedEvent: Call.Event.Reconnected,\n listener: Call.Listener.Reconnected\n ): this;\n /**\n * {@inheritDoc (Call:interface).(addListener:4)}\n */\n on(\n reconnectedEvent: Call.Event.Reconnected,\n listener: Call.Listener.Reconnected\n ): this;\n\n /**\n * Disconnected event. Raised when the call has disconnected.\n *\n * @remarks\n * This event can occur in \"naturally\" disconnected calls and calls\n * disconnected from issues such as network problems. If the SDK has detected\n * an issue that has caused the call to disconnect, then the error parameter\n * will be defined, otherwise it will be undefined.\n *\n * @example\n * ```typescript\n * call.addListener(Call.Event.Disconnected, (error) => {\n * // call has disconnected\n * // if a natural disconnect occurred, then error is `undefined`\n * // if an unnatural disconnect occurred, then error is defined\n * });\n * ```\n *\n * @param disconnectedEvent - The raised event string.\n * @param listener - A listener function that will be invoked when the event\n * is raised.\n * @returns - The call object.\n */\n addListener(\n disconnectedEvent: Call.Event.Disconnected,\n listener: Call.Listener.Disconnected\n ): this;\n /**\n * {@inheritDoc (Call:interface).(addListener:5)}\n */\n on(\n disconnectedEvent: Call.Event.Disconnected,\n listener: Call.Listener.Disconnected\n ): this;\n\n /**\n * Ringing event. Raised when the call has begun to ring.\n *\n * @example\n * ```typescript\n * call.addListener(Call.Event.Ringing, () => {\n * // call is ringing\n * });\n * ```\n *\n * @param ringingEvent - The raised event string.\n * @param listener - A listener function that will be invoked when the event\n * is raised.\n * @returns - The call object.\n */\n addListener(\n ringingEvent: Call.Event.Ringing,\n listener: Call.Listener.Ringing\n ): this;\n /**\n * {@inheritDoc (Call:interface).(addListener:6)}\n */\n on(ringingEvent: Call.Event.Ringing, listener: Call.Listener.Ringing): this;\n\n /**\n * Quality warnings changed event. Raised when a call quality warning is set\n * or unset. All \"ongoing\" call quality warnings are passed to the invoked\n * listener function.\n *\n * @example\n * ```typescript\n * call.addListener(\n * Call.Event.QualityWarningsChanged,\n * (\n * currentWarnings: Call.QualityWarning[],\n * previousWarnings: Call.QualityWarning[]\n * ) => {\n * // call quality warnings have changed\n * }\n * );\n * ```\n *\n * @param qualityWarningsChangedEvent - The raised event string.\n * @param listener - A listener function that will be invoked when the event\n * is raised.\n * @returns - The call object.\n */\n addListener(\n qualityWarningsChangedEvent: Call.Event.QualityWarningsChanged,\n listener: Call.Listener.QualityWarningsChanged\n ): this;\n /**\n * {@inheritDoc (Call:interface).(addListener:7)}\n */\n on(\n qualityWarningsChangedEvent: Call.Event.QualityWarningsChanged,\n listener: Call.Listener.QualityWarningsChanged\n ): this;\n\n /**\n * MessageReceived event. Raised when a {@link IncomingCallMessage} is\n * received.\n *\n * @example\n * ```typescript\n * call.addListener(Call.Event.MessageReceived, (message) => {\n * // callMessage received\n * })\n * ```\n *\n * @param messageReceivedEvent - The raised event string.\n * @param listener - A listener function that will be invoked when the event\n * is raised.\n * @returns - The callMessage object\n */\n addListener(\n messageReceivedEvent: Call.Event.MessageReceived,\n listener: Call.Listener.MessageReceived\n ): this;\n /** {@inheritDoc (Call:interface).(addListener:8)} */\n on(\n callMessageEvent: Call.Event.MessageReceived,\n listener: Call.Listener.MessageReceived\n ): this;\n\n /**\n * Generic event listener typings.\n * @param callEvent - The raised event string.\n * @param listener - A listener function that will be invoked when the event\n * is raised.\n * @returns - The call object.\n */\n addListener(callEvent: Call.Event, listener: Call.Listener.Generic): this;\n /**\n * {@inheritDoc (Call:interface).(addListener:9)}\n */\n on(callEvent: Call.Event, listener: Call.Listener.Generic): this;\n}\n\n/**\n * Provides access to information about a call, including the call parameters,\n * and exposes functionality for a call such as disconnecting, muting, and\n * holding.\n *\n * @remarks\n * Note that the call information is fetched as soon as possible from the native\n * layer, but there is no guarantee that all information is immediately\n * available. Methods such as `Call.getFrom()` or `Call.getTo()` may return\n * `undefined`.\n *\n * As call events are received from the native layer, call information will\n * propagate from the native layer to the JS layer and become available.\n * Therefore, it is good practice to read information from the call after an\n * event occurs, or as events occur.\n *\n * - See the {@link (Call:namespace).Event} enum for events emitted by `Call`\n * objects.\n * - See the {@link (Call:interface) | Call interface} for overloaded event\n * listening methods.\n * - See the {@link (Call:namespace) | Call namespace} for types and\n * enumerations used by this class.\n *\n * @public\n */\nexport class Call extends EventEmitter {\n /**\n * The `Uuid` of this call. Used to identify calls between the JS and native\n * layer so we can associate events and native functionality between the\n * layers.\n */\n private _uuid: Uuid;\n /**\n * Call custom parameters.\n */\n private _customParameters: CustomParameters;\n /**\n * Call `from` parameter.\n */\n private _from?: string;\n /**\n * Initial `connected` timestamp. Milliseconds since epoch.\n */\n private _initialConnectedTimestamp?: Date;\n /**\n * A boolean representing if the call is currently muted.\n */\n private _isMuted?: boolean;\n /**\n * A boolean representing if the call is currently on hold.\n */\n private _isOnHold?: boolean;\n /**\n * A string representing the SID of this call.\n */\n private _sid?: string;\n /**\n * The current state of the call.\n *\n * @remarks\n * See {@link (Call:namespace).State}.\n */\n private _state: Call.State;\n /**\n * Call `to` parameter.\n */\n private _to?: string;\n\n /**\n * Handlers for native call events. Set upon construction so we can\n * dynamically bind events to handlers.\n *\n * @privateRemarks\n * This is done by the constructor so this mapping isn't made every time the\n * {@link (Call:class)._handleNativeEvent} function is invoked.\n */\n private _nativeEventHandler: Record<\n NativeCallEventType,\n (callEvent: NativeCallEvent) => void\n >;\n\n /**\n * Constructor for the {@link (Call:class) | Call class}. This should not be\n * invoked by third-party code. All instances of the\n * {@link (Call:class) | Call class} should be made by the SDK and emitted by\n * {@link (Voice:class) | Voice objects}.\n *\n * @param nativeCallInfo - An object containing all of the data from the\n * native layer necessary to fully describe a call, as well as invoke native\n * functionality for the call.\n *\n * @internal\n */\n constructor({\n uuid,\n customParameters,\n from,\n sid,\n state,\n to,\n isMuted,\n isOnHold,\n initialConnectedTimestamp,\n }: NativeCallInfo) {\n super();\n\n this._uuid = uuid;\n this._customParameters = { ...customParameters };\n this._from = from;\n this._sid = sid;\n this._state = typeof state === 'string' ? state : Call.State.Connecting;\n this._to = to;\n this._isMuted = isMuted;\n this._isOnHold = isOnHold;\n this._initialConnectedTimestamp = initialConnectedTimestamp\n ? new Date(initialConnectedTimestamp)\n : undefined;\n\n this._nativeEventHandler = {\n /**\n * Call State\n */\n [Constants.CallEventConnected]: this._handleConnectedEvent,\n [Constants.CallEventConnectFailure]: this._handleConnectFailureEvent,\n [Constants.CallEventDisconnected]: this._handleDisconnectedEvent,\n [Constants.CallEventReconnected]: this._handleReconnectedEvent,\n [Constants.CallEventReconnecting]: this._handleReconnectingEvent,\n [Constants.CallEventRinging]: this._handleRingingEvent,\n\n /**\n * Call Quality\n */\n [Constants.CallEventQualityWarningsChanged]:\n this._handleQualityWarningsChangedEvent,\n\n /**\n * Call Message\n */\n [Constants.CallEventMessageReceived]: this._handleMessageReceivedEvent,\n };\n\n NativeEventEmitter.addListener(\n Constants.ScopeCall,\n this._handleNativeEvent\n );\n }\n\n /**\n * This intermediate native call event handler acts as a \"gate\", only\n * executing the actual call event handler (such as `Connected`) if this call\n * object matches the `Uuid` of the call that had an event raised.\n * @param nativeCallEvent - A call event directly from the native layer.\n */\n private _handleNativeEvent = (nativeCallEvent: NativeCallEvent) => {\n const { type, call: callInfo } = nativeCallEvent;\n\n const handler = this._nativeEventHandler[type];\n if (typeof handler === 'undefined') {\n throw new Error(\n `Unknown call event type received from the native layer: \"${type}\".`\n );\n }\n\n if (callInfo.uuid === this._uuid) {\n handler(nativeCallEvent);\n }\n };\n\n /**\n * Helper function to update the state of the call when a call event occurs\n * that necessitates an update, i.e. upon a\n * {@link (Call:namespace).Event.Connected | Connected event} we want to\n * update the state of the call to also reflect the\n * {@link (Call:namespace).State.Connected | Connected state}.\n * @param nativeCallEvent - The native call event.\n */\n private _update({\n type,\n call: { from, initialConnectedTimestamp, sid, to },\n }: NativeCallEvent) {\n const newState = eventTypeStateMap[type];\n if (typeof newState === 'string') {\n this._state = newState;\n }\n this._from = from;\n this._initialConnectedTimestamp = initialConnectedTimestamp\n ? new Date(initialConnectedTimestamp)\n : undefined;\n this._sid = sid;\n this._to = to;\n }\n\n /**\n * Handler for the the {@link (Call:namespace).Event.Connected} event.\n * @param nativeCallEvent - The native call event.\n */\n private _handleConnectedEvent = (nativeCallEvent: NativeCallEvent) => {\n if (nativeCallEvent.type !== Constants.CallEventConnected) {\n throw new Error(\n 'Incorrect \"call#connected\" handler called for type ' +\n `\"${nativeCallEvent.type}\".`\n );\n }\n\n this._update(nativeCallEvent);\n\n this.emit(Call.Event.Connected);\n };\n\n /**\n * Handler for the the {@link (Call:namespace).Event.ConnectFailure} event.\n * @param nativeCallEvent - The native call event.\n */\n private _handleConnectFailureEvent = (nativeCallEvent: NativeCallEvent) => {\n if (nativeCallEvent.type !== Constants.CallEventConnectFailure) {\n throw new Error(\n 'Incorrect \"call#connectFailure\" handler called for type ' +\n `\"${nativeCallEvent.type}\".`\n );\n }\n\n this._update(nativeCallEvent);\n\n const { message, code } = nativeCallEvent.error;\n const error = constructTwilioError(message, code);\n this.emit(Call.Event.ConnectFailure, error);\n };\n\n /**\n * Handler for the the {@link (Call:namespace).Event.Disconnected} event.\n * @param nativeCallEvent - The native call event.\n */\n private _handleDisconnectedEvent = (nativeCallEvent: NativeCallEvent) => {\n if (nativeCallEvent.type !== Constants.CallEventDisconnected) {\n throw new Error(\n 'Incorrect \"call#disconnected\" handler called for type ' +\n `\"${nativeCallEvent.type}\".`\n );\n }\n\n this._update(nativeCallEvent);\n\n if (nativeCallEvent.error) {\n const { message, code } = nativeCallEvent.error;\n const error = constructTwilioError(message, code);\n this.emit(Call.Event.Disconnected, error);\n } else {\n this.emit(Call.Event.Disconnected);\n }\n };\n\n /**\n * Handler for the the {@link (Call:namespace).Event.Reconnecting} event.\n * @param nativeCallEvent - The native call event.\n */\n private _handleReconnectingEvent = (nativeCallEvent: NativeCallEvent) => {\n if (nativeCallEvent.type !== Constants.CallEventReconnecting) {\n throw new Error(\n 'Incorrect \"call#reconnecting\" handler called for type ' +\n `\"${nativeCallEvent.type}\".`\n );\n }\n\n this._update(nativeCallEvent);\n\n const { message, code } = nativeCallEvent.error;\n const error = constructTwilioError(message, code);\n this.emit(Call.Event.Reconnecting, error);\n };\n\n /**\n * Handler for the the {@link (Call:namespace).Event.Reconnected} event.\n * @param nativeCallEvent - The native call event.\n */\n private _handleReconnectedEvent = (nativeCallEvent: NativeCallEvent) => {\n if (nativeCallEvent.type !== Constants.CallEventReconnected) {\n throw new Error(\n 'Incorrect \"call#reconnected\" handler called for type ' +\n `\"${nativeCallEvent.type}\".`\n );\n }\n\n this._update(nativeCallEvent);\n\n this.emit(Call.Event.Reconnected);\n };\n\n /**\n * Handler for the the {@link (Call:namespace).Event.Ringing} event.\n * @param nativeCallEvent - The native call event.\n */\n private _handleRingingEvent = (nativeCallEvent: NativeCallEvent) => {\n if (nativeCallEvent.type !== Constants.CallEventRinging) {\n throw new Error(\n 'Incorrect \"call#ringing\" handler called for type ' +\n `\"${nativeCallEvent.type}\".`\n );\n }\n\n this._update(nativeCallEvent);\n\n this.emit(Call.Event.Ringing);\n };\n\n /**\n * Handler for the the {@link (Call:namespace).Event.QualityWarningsChanged}\n * event.\n * @param nativeCallEvent - The native call event.\n */\n private _handleQualityWarningsChangedEvent = (\n nativeCallEvent: NativeCallEvent\n ) => {\n if (nativeCallEvent.type !== Constants.CallEventQualityWarningsChanged) {\n throw new Error(\n 'Incorrect \"call#qualityWarnings\" handler called for type ' +\n `\"${nativeCallEvent.type}\".`\n );\n }\n\n this._update(nativeCallEvent);\n\n const currentWarnings = nativeCallEvent[Constants.CallEventCurrentWarnings];\n const previousWarnings =\n nativeCallEvent[Constants.CallEventPreviousWarnings];\n\n this.emit(\n Call.Event.QualityWarningsChanged,\n currentWarnings as Call.QualityWarning[],\n previousWarnings as Call.QualityWarning[]\n );\n };\n\n /**\n * Handler for the {@link (Call:namespace).Event.MessageReceived} event.\n * @param nativeCallEvent - The native call event.\n */\n private _handleMessageReceivedEvent = (nativeCallEvent: NativeCallEvent) => {\n if (nativeCallEvent.type !== Constants.CallEventMessageReceived) {\n throw new Error(\n 'Incorrect \"call#Received\" handler called for type' +\n `\"${nativeCallEvent.type}`\n );\n }\n\n this._update(nativeCallEvent);\n\n const { callMessage: callMessageInfo } = nativeCallEvent;\n\n const incomingCallMessage = new IncomingCallMessage(callMessageInfo);\n\n this.emit(Call.Event.MessageReceived, incomingCallMessage);\n };\n\n /**\n * Disconnect this side of the call.\n * @returns\n * A `Promise` that\n * - Resolves when the call has disconnected.\n * - Rejects if the native layer cannot disconnect the call.\n */\n disconnect(): Promise<void> {\n return NativeModule.call_disconnect(this._uuid);\n }\n\n /**\n * Get the mute status of this side of the call.\n * @returns\n * - A boolean representing the muted status of the call.\n * - `undefined` if the call state has not yet been received from the native\n * layer.\n */\n isMuted(): boolean | undefined {\n return this._isMuted;\n }\n\n /**\n * Get the hold status of this side of the call.\n * @returns\n * - A boolean representing the hold status of the call.\n * - `undefined` if the call state has not yet been received from the native\n * layer.\n */\n isOnHold(): boolean | undefined {\n return this._isOnHold;\n }\n\n /**\n * Return a `Record` of custom parameters given to this call.\n * @returns\n * - A `Record` of custom parameters.\n */\n getCustomParameters(): CustomParameters {\n return this._customParameters;\n }\n\n /**\n * Get the value of the `from` parameter given to this call.\n * @returns\n * - A `String` representing the `from` parameter.\n * - `undefined` if the call information has not yet been received from the\n * native layer.\n */\n getFrom(): string | undefined {\n return this._from;\n }\n\n /**\n * Get the timestamp (milliseconds since epoch) of the call connected event.\n * @returns\n * - A `number` representing the timestamp.\n * - `undefined` if the call has not yet connected.\n */\n getInitialConnectedTimestamp(): Date | undefined {\n return this._initialConnectedTimestamp;\n }\n\n /**\n * Get the call `SID`.\n * @returns\n * - A `String` representing the `SID` of the call.\n * - `undefined` if the call information has not yet been received from the\n * native layer.\n */\n getSid(): string | undefined {\n return this._sid;\n }\n\n /**\n * Get the state of the call object, such as {@link (Call:namespace).State.Connected} or\n * {@link (Call:namespace).State.Disconnected}.\n * @returns\n * - A {@link (Call:namespace).State}.\n */\n getState(): Call.State {\n return this._state;\n }\n\n /**\n * Gets the `PeerConnection` `WebRTC` stats for the ongoing call.\n * @returns\n * A `Promise` that\n * - Resolves with a {@link RTCStats.StatsReport} object representing the\n * `WebRTC` `PeerConnection` stats of a call.\n * - Rejects when a {@link RTCStats.StatsReport} cannot be generated for a\n * call.\n */\n getStats(): Promise<RTCStats.StatsReport> {\n return NativeModule.call_getStats(this._uuid);\n }\n\n /**\n * Get the value of the `to` parameter given to this call.\n * @returns\n * - A `String` representing the `to` parameter.\n * - `undefined` if the call information has not yet been received from the\n * native layer.\n */\n getTo(): string | undefined {\n return this._to;\n }\n\n /**\n * Put this end of the call on hold or not on hold.\n *\n * @example\n * To put a call on hold\n * ```typescript\n * call.hold(true);\n * ```\n * @example\n * To take a call off hold\n * ```typescript\n * call.hold(false);\n * ```\n *\n * @param hold - A `boolean` representing whether or not to put this end of\n * the call on hold.\n *\n * @returns\n * A `Promise` that\n * - Resolves with the hold status when the call is put on hold or not on\n * hold.\n * - Rejects when the call is not able to be put on hold or not on hold.\n */\n async hold(hold: boolean): Promise<boolean> {\n this._isOnHold = await NativeModule.call_hold(this._uuid, hold);\n return this._isOnHold;\n }\n\n /**\n * Mute or unmute this end of the call.\n *\n * @example\n * To mute a call\n * ```typescript\n * call.mute(true);\n * ```\n *\n * @example\n * To unmute a call\n * ```typescript\n * call.mute(false);\n * ```\n *\n * @param mute - A `boolean` representing whether or not to mute this end of\n * the call.\n *\n * @returns\n * A `Promise` that\n * - Resolves with the muted status of the call when the call is muted or\n * unmuted.\n * - Rejects when the call is not able to be muted or unmuted.\n */\n async mute(mute: boolean): Promise<boolean> {\n this._isMuted = await NativeModule.call_mute(this._uuid, mute);\n return this._isMuted;\n }\n\n /**\n * Send DTMF digits.\n *\n * @example\n * To send the `0` dialtone:\n * ```typescript\n * call.sendDigits('0');\n * ```\n *\n * @example\n * To send the `0` and then `1` dialtone:\n * ```typescript\n * call.sendDigits('01');\n * ```\n *\n * @param digits - A sequence of DTMF digits in a string.\n *\n * @returns\n * A `Promise` that\n * - Resolves when the DTMF digits have been sent.\n * - Rejects when DTMF tones are not able to be sent.\n */\n sendDigits(digits: string): Promise<void> {\n return NativeModule.call_sendDigits(this._uuid, digits);\n }\n\n /**\n * Send a CallMessage.\n *\n * @example\n * To send a user-defined-message\n * ```typescript\n * const outgoingCallMessage: OutgoingCallMessage = await call.sendMessage({\n * content: { key1: 'This is a messsage from the parent call' },\n * contentType: 'application/json',\n * messageType: 'user-defined-message'\n * });\n *\n * outgoingCallMessage.addListener(OutgoingCallMessage.Event.Failure, (error) => {\n * // outgoingCallMessage failed, handle error\n * });\n *\n * outgoingCallMessage.addListener(OutgoingCallMessage.Event.Sent, () => {\n * // outgoingCallMessage sent\n * });\n * ```\n *\n * @param message - The call message to send.\n *\n * @returns\n * A `Promise` that\n * - Resolves with the OutgoingCallMessage object.\n * - Rejects when the message is unable to be sent.\n */\n async sendMessage(message: CallMessage): Promise<OutgoingCallMessage> {\n const { content, contentType, messageType } = validateCallMessage(message);\n\n const voiceEventSid = await NativeModule.call_sendMessage(\n this._uuid,\n content,\n contentType,\n messageType\n );\n\n const outgoingCallMessage = new OutgoingCallMessage({\n content,\n contentType,\n messageType,\n voiceEventSid,\n });\n\n return outgoingCallMessage;\n }\n\n /**\n * Post feedback about a call.\n *\n * @example\n * To report that a call had very significant audio latency:\n * ```typescript\n * call.postFeedback(Call.Score.Five, Call.Issue.AudioLatency);\n * ```\n *\n * @param score - A score representing the serverity of the issue being\n * reported.\n * @param issue - The issue being reported.\n * @returns\n * A `Promise` that\n * - Resolves when the feedback has been posted.\n * - Rejects when the feedback is unable to be sent.\n */\n async postFeedback(score: Call.Score, issue: Call.Issue): Promise<void> {\n if (!validScores.includes(score)) {\n throw new InvalidArgumentError(\n '\"score\" parameter invalid. Must be a member of the `Call.Score` enum.'\n );\n }\n\n if (!Object.values(Call.Issue).includes(issue)) {\n throw new InvalidArgumentError(\n '\"issue\" parameter invalid. Must be a member of the `Call.Issue` enum.'\n );\n }\n\n const nativeScore = scoreMap[score];\n const nativeIssue = issueMap[issue];\n\n return NativeModule.call_postFeedback(this._uuid, nativeScore, nativeIssue);\n }\n}\n\n/**\n * Namespace for enumerations and types used by\n * {@link (Call:class) | Call objects}.\n *\n * @remarks\n * - See also the {@link (Call:class) | Call class}.\n * - See also the {@link (Call:interface) | Call interface}.\n *\n * @public\n */\nexport namespace Call {\n /**\n * Enumeration of all event strings emitted by {@link (Call:class)} objects.\n */\n export enum Event {\n /**\n * Event string for the `Connected` event.\n * See {@link (Call:interface).(addListener:1)}.\n */\n 'Connected' = 'connected',\n\n /**\n * Event string for the `ConnectedFailure` event.\n * See {@link (Call:interface).(addListener:2)}.\n */\n 'ConnectFailure' = 'connectFailure',\n\n /**\n * Event string for the `Reconnecting` event.\n * See {@link (Call:interface).(addListener:3)}.\n */\n 'Reconnecting' = 'reconnecting',\n\n /**\n * Event string for the `Reconnected` event.\n * See {@link (Call:interface).(addListener:4)}.\n */\n 'Reconnected' = 'reconnected',\n\n /**\n * Event string for the `Disconnected` event.\n * See {@link (Call:interface).(addListener:5)}.\n */\n 'Disconnected' = 'disconnected',\n\n /**\n * Event string for the `Ringing` event.\n * See {@link (Call:interface).(addListener:6)}.\n */\n 'Ringing' = 'ringing',\n\n /**\n * Event string for the `QualityWarningsChanged` event.\n * See {@link (Call:interface).(addListener:7)}.\n */\n 'QualityWarningsChanged' = 'qualityWarningsChanged',\n\n /**\n * Event string for the `MessageReceived` event.\n * See {@link (Call:interface).(addListener:8)}\n */\n 'MessageReceived' = 'messageReceived',\n }\n\n /**\n * An enumeration of all possible {@link (Call:class) | Call object} states.\n */\n export enum State {\n /**\n * Call `Connected` state.\n *\n * Occurs when the `Connected` and `Reconnected` event is raised.\n *\n * @remarks\n *\n * See {@link (Call:interface).(addListener:1)}.\n *\n * See {@link (Call:interface).(addListener:4)}.\n */\n 'Connected' = Constants.CallStateConnected,\n\n /**\n * Call `Connecting` state.\n *\n * The default state of an outgoing call.\n */\n 'Connecting' = Constants.CallStateConnecting,\n\n /**\n * Call `Disconnected` state.\n *\n * Occurs when the `Disconnected` or `ConnectFailure` event is raised.\n *\n * @remarks\n *\n * See {@link (Call:interface).(addListener:5)}.\n *\n * See {@link (Call:interface).(addListener:2)}.\n */\n 'Disconnected' = Constants.CallStateDisconnected,\n\n /**\n * Call `Reconnecting` state.\n *\n * Occurs when the `Reconnecting` event is raised.\n *\n * @remarks\n *\n * See {@link (Call:interface).(addListener:3)}.\n */\n 'Reconnecting' = Constants.CallStateReconnecting,\n\n /**\n * Call `Ringing` state. Occurs when the `Ringing` event is raised.\n *\n * @remarks\n *\n * See {@link (Call:interface).(addListener:6)}.\n */\n 'Ringing' = Constants.CallStateRinging,\n }\n\n /**\n * An enumeration of all call quality-warning types.\n */\n export enum QualityWarning {\n /**\n * Raised when the call detects constant audio input, such as silence.\n */\n 'ConstantAudioInputLevel' = 'constant-audio-input-level',\n /**\n * Raised when the network encounters high jitter.\n */\n 'HighJitter' = 'high-jitter',\n /**\n * Raised when the network encounters high packet loss.\n */\n 'HighPacketLoss' = 'high-packet-loss',\n /**\n * Raised when the network encounters high packet round-trip-time.\n */\n 'HighRtt' = 'high-rtt',\n /**\n * Raised when the call detects a low mean-opinion-score or MOS.\n */\n 'LowMos' = 'low-mos',\n }\n\n /**\n * An enumeration of all scores that could be used to rate the experience of\n * a call or issues encountered during the call.\n */\n export enum Score {\n /**\n * An issue was not encountered or there is no desire to report said issue.\n */\n 'NotReported' = 0,\n /**\n * An issue had severity approximately 1/5.\n */\n 'One' = 1,\n /**\n * An issue had severity approximately 2/5.\n */\n 'Two' = 2,\n /**\n * An issue had severity approximately 3/5.\n */\n 'Three' = 3,\n /**\n * An issue had severity approximately 4/5.\n */\n 'Four' = 4,\n /**\n * An issue had severity approximately 5/5.\n */\n 'Five' = 5,\n }\n\n /**\n * An enumeration of call issues that can be reported.\n */\n export enum Issue {\n /**\n * No issue is reported.\n */\n 'NotReported' = 'not-reported',\n /**\n * The call was dropped unexpectedly.\n */\n 'DroppedCall' = 'dropped-call',\n /**\n * The call encountered significant audio latency.\n */\n 'AudioLatency' = 'audio-latency',\n /**\n * One party of the call could not hear the other callee.\n */\n 'OneWayAudio' = 'one-way-audio',\n /**\n * Call audio was choppy.\n */\n 'ChoppyAudio' = 'choppy-audio',\n /**\n * Call audio had significant noise.\n */\n 'NoisyCall' = 'noisy-call',\n /**\n * Call audio had significant echo.\n */\n 'Echo' = 'echo',\n }\n\n /**\n * Listener types for all events emitted by a\n * {@link (Call:class) | Call object.}\n */\n export namespace Listener {\n /**\n * Connected event listener. This should be the function signature of any\n * event listener bound to the {@link (Call:namespace).Event.Connected}\n * event.\n *\n * @remarks\n * See {@link (Call:interface).(addListener:1)}.\n */\n export type Connected = () => void;\n\n /**\n * Connect failure event listener. This should be the function signature of\n * any event listener bound to the\n * {@link (Call:namespace).Event.ConnectFailure} event.\n *\n * @remarks\n * See {@link (Call:interface).(addListener:2)}.\n *\n * See {@link TwilioErrors} for all error classes.\n */\n export type ConnectFailure = (error: TwilioError) => void;\n\n /**\n * Reconnecting event listener. This should be the function signature of any\n * event listener bound to the {@link (Call:namespace).Event.Reconnecting}\n * event.\n *\n * @remarks\n * See {@link (Call:interface).(addListener:3)}.\n *\n * See {@link TwilioErrors} for all error classes.\n */\n export type Reconnecting = (error: TwilioError) => void;\n\n /**\n * Reconnected event listener. This should be the function signature of any\n * event listener bound to the {@link (Call:namespace).Event.Reconnected}\n * event.\n *\n * @remarks\n * See {@link (Call:interface).(addListener:4)}.\n */\n export type Reconnected = () => void;\n\n /**\n * Disconnected event listener. This should be the function signature of any\n * event listener bound to the {@link (Call:namespace).Event.Disconnected}\n * event.\n *\n * @remarks\n * See {@link (Call:interface).(addListener:5)}.\n *\n * See {@link TwilioErrors} for all error classes.\n */\n export type Disconnected = (error?: TwilioError) => void;\n\n /**\n * Ringing event listener. This should be the function signature of any\n * event listener bound to the {@link (Call:namespace).Event.Ringing} event.\n *\n * @remarks\n * See {@link (Call:interface).(addListener:6)}.\n */\n export type Ringing = () => void;\n\n /**\n * Quality warnings changed event listener. This should be the function\n * signature of any event listener bound to the\n * {@link (Call:namespace).Event.QualityWarningsChanged} event.\n *\n * @remarks\n * See {@link (Call:interface).(addListener:7)}.\n */\n export type QualityWarningsChanged = (\n currentQualityWarnings: Call.QualityWarning[],\n previousQualityWarnings: Call.QualityWarning[]\n ) => void;\n\n /**\n * CallMessage received event listener. This should be the function signature of\n * any event listener bound to the {@link (Call:namespace).Event.MessageReceived} event.\n *\n * @remarks\n * See {@link (Call:interface).(addListener:8)}.\n */\n export type MessageReceived = (\n incomingCallMessage: IncomingCallMessage\n ) => void;\n\n /**\n * Generic event listener. This should be the function signature of any\n * event listener bound to any call event.\n *\n * @remarks\n * See {@link (Call:interface).(addListener:9)}.\n */\n export type Generic = (...args: any[]) => void;\n }\n}\n\n/**\n * Mapping of {@link (Call:namespace).Event | Call events} to\n * {@link (Call:namespace).State | Call states}.\n *\n * @remarks\n * Note that this mapping is not a 1:1 bijection. Not every event coming from\n * the native layer has a relevant state, and some events share a state.\n * Therefore, this `Record` needs to be marked as `Partial` and\n * undefined-checking logic is needed when using this mapping.\n *\n * @internal\n */\nconst eventTypeStateMap: Partial<Record<NativeCallEventType, Call.State>> = {\n [Constants.CallEventConnected]: Call.State.Connected,\n [Constants.CallEventConnectFailure]: Call.State.Disconnected,\n [Constants.CallEventDisconnected]: Call.State.Disconnected,\n [Constants.CallEventReconnecting]: Call.State.Reconnecting,\n [Constants.CallEventReconnected]: Call.State.Connected,\n [Constants.CallEventRinging]: Call.State.Ringing,\n};\n\n/**\n * Array of valid call scores.\n *\n * @internal\n */\nconst validScores = [\n Call.Score.NotReported,\n Call.Score.One,\n Call.Score.Two,\n Call.Score.Three,\n Call.Score.Four,\n Call.Score.Five,\n];\n\n/**\n * Mapping of the {@link (Call:namespace).Score | Call score} enum to\n * cross-platform common constants.\n *\n * @internal\n */\nconst scoreMap: Record<Call.Score, NativeCallFeedbackScore> = {\n [Call.Score.NotReported]: Constants.CallFeedbackScoreNotReported,\n [Call.Score.One]: Constants.CallFeedbackScoreOne,\n [Call.Score.Two]: Constants.CallFeedbackScoreTwo,\n [Call.Score.Three]: Constants.CallFeedbackScoreThree,\n [Call.Score.Four]: Constants.CallFeedbackScoreFour,\n [Call.Score.Five]: Constants.CallFeedbackScoreFive,\n};\n\n/**\n * Mapping of the {@link (Call:namespace).Issue | Call issue} enum to\n * cross-platform common constants.\n *\n * @internal\n */\nconst issueMap: Record<Call.Issue, NativeCallFeedbackIssue> = {\n [Call.Issue.AudioLatency]: Constants.CallFeedbackIssueAudioLatency,\n [Call.Issue.ChoppyAudio]: Constants.CallFeedbackIssueChoppyAudio,\n [Call.Issue.DroppedCall]: Constants.CallFeedbackIssueDroppedCall,\n [Call.Issue.Echo]: Constants.CallFeedbackIssueEcho,\n [Call.Issue.NoisyCall]: Constants.CallFeedbackIssueNoisyCall,\n [Call.Issue.NotReported]: Constants.CallFeedbackIssueNotReported,\n [Call.Issue.OneWayAudio]: Constants.CallFeedbackIssueOneWayAudio,\n};\n"]}
|
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CallInvite = void 0;
|
|
7
|
+
|
|
8
|
+
var _eventemitter = require("eventemitter3");
|
|
9
|
+
|
|
10
|
+
var _Call = require("./Call");
|
|
11
|
+
|
|
12
|
+
var _common = require("./common");
|
|
13
|
+
|
|
14
|
+
var _InvalidStateError = require("./error/InvalidStateError");
|
|
15
|
+
|
|
16
|
+
var _TwilioError = require("./error/TwilioError");
|
|
17
|
+
|
|
18
|
+
var _UnsupportedPlatformError = require("./error/UnsupportedPlatformError");
|
|
19
|
+
|
|
20
|
+
var _utility = require("./error/utility");
|
|
21
|
+
|
|
22
|
+
var _CallMessage = require("./CallMessage/CallMessage");
|
|
23
|
+
|
|
24
|
+
var _IncomingCallMessage = require("./CallMessage/IncomingCallMessage");
|
|
25
|
+
|
|
26
|
+
var _OutgoingCallMessage = require("./CallMessage/OutgoingCallMessage");
|
|
27
|
+
|
|
28
|
+
var _constants = require("./constants");
|
|
29
|
+
|
|
30
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Provides access to information about a call invite, including the call
|
|
34
|
+
* parameters, and exposes functionality to accept or decline a call.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
*
|
|
38
|
+
* Note that when a `CallInvite` is acted upon (i.e. when
|
|
39
|
+
* {@link (CallInvite:class).accept} or {@link (CallInvite:class).reject} is
|
|
40
|
+
* invoked), then the `CallInvite` is "settled".
|
|
41
|
+
*
|
|
42
|
+
* The state of the `CallInvite` is changed from
|
|
43
|
+
* {@link (CallInvite:namespace).State.Pending} to
|
|
44
|
+
* {@link (CallInvite:namespace).State.Accepted} or
|
|
45
|
+
* {@link (CallInvite:namespace).State.Rejected} and the `CallInvite` can no
|
|
46
|
+
* longer be acted upon further.
|
|
47
|
+
*
|
|
48
|
+
* Further action after "settling" a `CallInvite` will throw an error.
|
|
49
|
+
*
|
|
50
|
+
* - See the {@link (CallInvite:namespace) | CallInvite namespace} for
|
|
51
|
+
* enumerations and types used by this class.
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
class CallInvite extends _eventemitter.EventEmitter {
|
|
56
|
+
/**
|
|
57
|
+
* The current state of the call invite.
|
|
58
|
+
*
|
|
59
|
+
* @remarks
|
|
60
|
+
* See {@link (CallInvite:namespace).State}.
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The `Uuid` of this call invite. Used to identify calls between the JS and
|
|
65
|
+
* native layer so we can associate events and native functionality between
|
|
66
|
+
* the layers.
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A string representing the SID of this call.
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Call custom parameters.
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Call `from` parameter.
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Call `to` parameter.
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* These objects should not be instantiated by consumers of the SDK. All
|
|
87
|
+
* instances of the `CallInvite` class should be emitted by the SDK.
|
|
88
|
+
*
|
|
89
|
+
* @param nativeCallInviteInfo - A dataobject containing the native
|
|
90
|
+
* information of a call invite.
|
|
91
|
+
* @param state - Mocking options for testing.
|
|
92
|
+
*
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
constructor({
|
|
96
|
+
uuid,
|
|
97
|
+
callSid,
|
|
98
|
+
customParameters,
|
|
99
|
+
from,
|
|
100
|
+
to
|
|
101
|
+
}, state) {
|
|
102
|
+
super();
|
|
103
|
+
|
|
104
|
+
_defineProperty(this, "_state", void 0);
|
|
105
|
+
|
|
106
|
+
_defineProperty(this, "_uuid", void 0);
|
|
107
|
+
|
|
108
|
+
_defineProperty(this, "_callSid", void 0);
|
|
109
|
+
|
|
110
|
+
_defineProperty(this, "_customParameters", void 0);
|
|
111
|
+
|
|
112
|
+
_defineProperty(this, "_from", void 0);
|
|
113
|
+
|
|
114
|
+
_defineProperty(this, "_to", void 0);
|
|
115
|
+
|
|
116
|
+
_defineProperty(this, "_handleNativeCallInviteEvent", nativeCallInviteEvent => {
|
|
117
|
+
if (typeof nativeCallInviteEvent !== 'object') {
|
|
118
|
+
throw new _TwilioError.TwilioError(`Received a "${typeof nativeCallInviteEvent}" native call invite event.`);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (nativeCallInviteEvent === null) {
|
|
122
|
+
throw new _TwilioError.TwilioError('Received a null native call invite event.');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (typeof nativeCallInviteEvent.callSid !== 'string') {
|
|
126
|
+
throw new _TwilioError.TwilioError('Received a native call invite event without a call SID.');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (nativeCallInviteEvent.callSid !== this._callSid) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
switch (nativeCallInviteEvent.type) {
|
|
134
|
+
case _constants.Constants.CallInviteEventTypeValueAccepted:
|
|
135
|
+
return this._handleCallInviteAccepted(nativeCallInviteEvent);
|
|
136
|
+
|
|
137
|
+
case _constants.Constants.CallInviteEventTypeValueRejected:
|
|
138
|
+
return this._handleCallInviteRejected();
|
|
139
|
+
|
|
140
|
+
case _constants.Constants.CallInviteEventTypeValueCancelled:
|
|
141
|
+
return this._handleCallInviteCancelled(nativeCallInviteEvent);
|
|
142
|
+
|
|
143
|
+
case _constants.Constants.CallInviteEventTypeValueNotificationTapped:
|
|
144
|
+
return this._handleCallInviteNotificationTapped();
|
|
145
|
+
|
|
146
|
+
case _constants.Constants.CallEventMessageReceived:
|
|
147
|
+
return this._handleMessageReceivedEvent(nativeCallInviteEvent);
|
|
148
|
+
|
|
149
|
+
default:
|
|
150
|
+
return this._handleUnexpectedCallInviteEventType(nativeCallInviteEvent);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
_defineProperty(this, "_handleMessageReceivedEvent", nativeCallInviteEvent => {
|
|
155
|
+
const {
|
|
156
|
+
callMessage: callMessageInfo
|
|
157
|
+
} = nativeCallInviteEvent;
|
|
158
|
+
const callMessage = new _IncomingCallMessage.IncomingCallMessage(callMessageInfo);
|
|
159
|
+
this.emit(CallInvite.Event.MessageReceived, callMessage);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
_defineProperty(this, "_handleCallInviteAccepted", ({
|
|
163
|
+
callInvite
|
|
164
|
+
}) => {
|
|
165
|
+
this._state = CallInvite.State.Accepted;
|
|
166
|
+
const callInfo = {
|
|
167
|
+
uuid: callInvite.uuid,
|
|
168
|
+
customParameters: callInvite.customParameters,
|
|
169
|
+
sid: callInvite.callSid,
|
|
170
|
+
from: callInvite.from,
|
|
171
|
+
to: callInvite.to
|
|
172
|
+
};
|
|
173
|
+
const call = new _Call.Call(callInfo);
|
|
174
|
+
this.emit(CallInvite.Event.Accepted, call);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
_defineProperty(this, "_handleCallInviteRejected", () => {
|
|
178
|
+
this._state = CallInvite.State.Rejected;
|
|
179
|
+
this.emit(CallInvite.Event.Rejected);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
_defineProperty(this, "_handleCallInviteCancelled", nativeCallInviteCancelledEvent => {
|
|
183
|
+
this._state = CallInvite.State.Cancelled;
|
|
184
|
+
const error = nativeCallInviteCancelledEvent.error ? (0, _utility.constructTwilioError)(nativeCallInviteCancelledEvent.error.message, nativeCallInviteCancelledEvent.error.code) : undefined;
|
|
185
|
+
this.emit(CallInvite.Event.Cancelled, error);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
_defineProperty(this, "_handleCallInviteNotificationTapped", () => {
|
|
189
|
+
this.emit(CallInvite.Event.NotificationTapped);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
this._uuid = uuid;
|
|
193
|
+
this._callSid = callSid;
|
|
194
|
+
this._customParameters = { ...customParameters
|
|
195
|
+
};
|
|
196
|
+
this._from = from;
|
|
197
|
+
this._to = to;
|
|
198
|
+
this._state = state;
|
|
199
|
+
|
|
200
|
+
_common.NativeEventEmitter.addListener(_constants.Constants.ScopeCallInvite, this._handleNativeCallInviteEvent);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* This helper function serves as both a runtime-check error log and a
|
|
204
|
+
* compile-time type-guard. If the switch-case statement below is non-
|
|
205
|
+
* exhaustive, then the type passed to this function will _not_ have type
|
|
206
|
+
* `never`.
|
|
207
|
+
*/
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
_handleUnexpectedCallInviteEventType(event) {
|
|
211
|
+
throw new _TwilioError.TwilioError(`Unknown event type "${event === null || event === void 0 ? void 0 : event.type}" reached call invite.`);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* This intermediate native call invite event handler acts as a "gate", only
|
|
215
|
+
* executing the actual call invite event handler (such as `Accepted`) if
|
|
216
|
+
* this call invite object matches the `Uuid` of the call invite that had an
|
|
217
|
+
* event raised.
|
|
218
|
+
* @param nativeCallInviteEvent - A call invite event directly from the native
|
|
219
|
+
* layer.
|
|
220
|
+
*/
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Accept a call invite. Sets the state of this call invite to
|
|
225
|
+
* {@link (CallInvite:namespace).State.Accepted}.
|
|
226
|
+
* @param options - Options to pass to the native layer when accepting the
|
|
227
|
+
* call.
|
|
228
|
+
* @returns
|
|
229
|
+
* - Resolves when a {@link (Call:class) | Call object} associated with this
|
|
230
|
+
* {@link (CallInvite:class)} has been created.
|
|
231
|
+
*/
|
|
232
|
+
async accept(options = {}) {
|
|
233
|
+
if (this._state !== CallInvite.State.Pending) {
|
|
234
|
+
throw new _InvalidStateError.InvalidStateError(`Call in state "${this._state}", ` + `expected state "${CallInvite.State.Pending}".`);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const acceptResult = await _common.NativeModule.callInvite_accept(this._uuid, options).then(callInfo => {
|
|
238
|
+
return {
|
|
239
|
+
type: 'ok',
|
|
240
|
+
callInfo
|
|
241
|
+
};
|
|
242
|
+
}).catch(error => {
|
|
243
|
+
const code = error.userInfo.code;
|
|
244
|
+
const message = error.userInfo.message;
|
|
245
|
+
return {
|
|
246
|
+
type: 'err',
|
|
247
|
+
message,
|
|
248
|
+
code
|
|
249
|
+
};
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
if (acceptResult.type === 'err') {
|
|
253
|
+
throw (0, _utility.constructTwilioError)(acceptResult.message, acceptResult.code);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return new _Call.Call(acceptResult.callInfo);
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Reject a call invite. Sets the state of this call invite to
|
|
260
|
+
* {@link (CallInvite:namespace).State.Rejected}.
|
|
261
|
+
* @returns
|
|
262
|
+
* - Resolves when the {@link (CallInvite:class)} has been rejected.
|
|
263
|
+
*/
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
async reject() {
|
|
267
|
+
if (this._state !== CallInvite.State.Pending) {
|
|
268
|
+
throw new _InvalidStateError.InvalidStateError(`Call in state "${this._state}", ` + `expected state "${CallInvite.State.Pending}".`);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
await _common.NativeModule.callInvite_reject(this._uuid);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Check if a `CallInvite` is valid.
|
|
275
|
+
*
|
|
276
|
+
* @returns
|
|
277
|
+
* - TODO
|
|
278
|
+
*
|
|
279
|
+
* @alpha
|
|
280
|
+
*/
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
isValid() {
|
|
284
|
+
return _common.NativeModule.callInvite_isValid(this._uuid);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Get the call SID associated with this `CallInvite` class.
|
|
288
|
+
* @returns - A string representing the call SID.
|
|
289
|
+
*/
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
getCallSid() {
|
|
293
|
+
return this._callSid;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Get the custom parameters of the call associated with this `CallInvite`
|
|
297
|
+
* class.
|
|
298
|
+
* @returns - A `Record` of custom parameters.
|
|
299
|
+
*/
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
getCustomParameters() {
|
|
303
|
+
return this._customParameters;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Get the `from` parameter of the call associated with this `CallInvite`
|
|
307
|
+
* class.
|
|
308
|
+
* @returns - A `string` representing the `from` parameter.
|
|
309
|
+
*/
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
getFrom() {
|
|
313
|
+
return this._from;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Get the `state` of the `CallInvite`.
|
|
317
|
+
* @returns - The `state` of this `CallInvite`.
|
|
318
|
+
*/
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
getState() {
|
|
322
|
+
return this._state;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Get the `to` parameter of the call associated with this `CallInvite`
|
|
326
|
+
* class.
|
|
327
|
+
* @returns - A `string` representing the `to` parameter.
|
|
328
|
+
*/
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
getTo() {
|
|
332
|
+
return this._to;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Send a CallMessage.
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* To send a user-defined-message
|
|
339
|
+
* ```typescript
|
|
340
|
+
* const outgoingCallMessage: OutgoingCallMessage = await callInvite.sendMessage({
|
|
341
|
+
* content: { key1: 'This is a messsage from the parent call invite' },
|
|
342
|
+
* contentType: 'application/json',
|
|
343
|
+
* messageType: 'user-defined-message'
|
|
344
|
+
* });
|
|
345
|
+
*
|
|
346
|
+
* outgoingCallMessage.addListener(OutgoingCallMessage.Event.Failure, (error) => {
|
|
347
|
+
* // outgoingCallMessage failed, handle error
|
|
348
|
+
* });
|
|
349
|
+
*
|
|
350
|
+
* outgoingCallMessage.addListener(OutgoingCallMessage.Event.Sent, () => {
|
|
351
|
+
* // outgoingCallMessage sent
|
|
352
|
+
* });
|
|
353
|
+
* ```
|
|
354
|
+
*
|
|
355
|
+
* @param message - The call message to send.
|
|
356
|
+
*
|
|
357
|
+
* @returns
|
|
358
|
+
* A `Promise` that
|
|
359
|
+
* - Resolves with the OutgoingCallMessage object.
|
|
360
|
+
* - Rejects when the message is unable to be sent.
|
|
361
|
+
*/
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
async sendMessage(message) {
|
|
365
|
+
const {
|
|
366
|
+
content,
|
|
367
|
+
contentType,
|
|
368
|
+
messageType
|
|
369
|
+
} = (0, _CallMessage.validateCallMessage)(message);
|
|
370
|
+
const voiceEventSid = await _common.NativeModule.call_sendMessage(this._uuid, content, contentType, messageType);
|
|
371
|
+
const outgoingCallMessage = new _OutgoingCallMessage.OutgoingCallMessage({
|
|
372
|
+
content,
|
|
373
|
+
contentType,
|
|
374
|
+
messageType,
|
|
375
|
+
voiceEventSid
|
|
376
|
+
});
|
|
377
|
+
return outgoingCallMessage;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Update the caller name displayed in the iOS system incoming call screen.
|
|
381
|
+
*
|
|
382
|
+
* @param newHandle - The new value of the caller's name.
|
|
383
|
+
*
|
|
384
|
+
* @remarks
|
|
385
|
+
* Unsupported platforms:
|
|
386
|
+
* - Android
|
|
387
|
+
*
|
|
388
|
+
* This API is specific to iOS and unavailable in Android. Invoke this method
|
|
389
|
+
* after the incoming call has been reported to CallKit and before the call
|
|
390
|
+
* has been accepted. For example, perform an async request to your app server
|
|
391
|
+
* to fetch the full name of the caller and use this method to replace the
|
|
392
|
+
* default caller name in `from`.
|
|
393
|
+
*
|
|
394
|
+
* @returns
|
|
395
|
+
* - Resolves when the caller name has been updated.
|
|
396
|
+
*/
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
async updateCallerHandle(newHandle) {
|
|
400
|
+
switch (_common.Platform.OS) {
|
|
401
|
+
case 'ios':
|
|
402
|
+
return _common.NativeModule.callInvite_updateCallerHandle(this._uuid, newHandle);
|
|
403
|
+
|
|
404
|
+
default:
|
|
405
|
+
throw new _UnsupportedPlatformError.UnsupportedPlatformError(`Unsupported platform "${_common.Platform.OS}". This method is only supported on iOS.`);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Provides enumerations and types used by a {@link (CallInvite:class)
|
|
412
|
+
* | CallInvite object}.
|
|
413
|
+
*
|
|
414
|
+
* @remarks
|
|
415
|
+
* - See also the {@link (CallInvite:class) | CallInvite class}.
|
|
416
|
+
*
|
|
417
|
+
* @public
|
|
418
|
+
*/
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
exports.CallInvite = CallInvite;
|
|
422
|
+
|
|
423
|
+
(function (_CallInvite) {
|
|
424
|
+
/**
|
|
425
|
+
* Options to pass to the native layer when accepting the call.
|
|
426
|
+
*/
|
|
427
|
+
let State;
|
|
428
|
+
|
|
429
|
+
(function (State) {
|
|
430
|
+
State["Pending"] = "pending";
|
|
431
|
+
State["Accepted"] = "accepted";
|
|
432
|
+
State["Rejected"] = "rejected";
|
|
433
|
+
State["Cancelled"] = "cancelled";
|
|
434
|
+
})(State || (State = {}));
|
|
435
|
+
|
|
436
|
+
_CallInvite.State = State;
|
|
437
|
+
let Event;
|
|
438
|
+
|
|
439
|
+
(function (Event) {
|
|
440
|
+
Event["Accepted"] = "accepted";
|
|
441
|
+
Event["Rejected"] = "rejected";
|
|
442
|
+
Event["Cancelled"] = "cancelled";
|
|
443
|
+
Event["NotificationTapped"] = "notificationTapped";
|
|
444
|
+
Event["MessageReceived"] = "messageReceived";
|
|
445
|
+
})(Event || (Event = {}));
|
|
446
|
+
|
|
447
|
+
_CallInvite.Event = Event;
|
|
448
|
+
let Listener;
|
|
449
|
+
|
|
450
|
+
(function (_Listener) {})(Listener || (Listener = _CallInvite.Listener || (_CallInvite.Listener = {})));
|
|
451
|
+
})(CallInvite || (exports.CallInvite = CallInvite = {}));
|
|
452
|
+
//# sourceMappingURL=CallInvite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["CallInvite.tsx"],"names":["CallInvite","EventEmitter","constructor","uuid","callSid","customParameters","from","to","state","nativeCallInviteEvent","TwilioError","_callSid","type","Constants","CallInviteEventTypeValueAccepted","_handleCallInviteAccepted","CallInviteEventTypeValueRejected","_handleCallInviteRejected","CallInviteEventTypeValueCancelled","_handleCallInviteCancelled","CallInviteEventTypeValueNotificationTapped","_handleCallInviteNotificationTapped","CallEventMessageReceived","_handleMessageReceivedEvent","_handleUnexpectedCallInviteEventType","callMessage","callMessageInfo","IncomingCallMessage","emit","Event","MessageReceived","callInvite","_state","State","Accepted","callInfo","sid","call","Call","Rejected","nativeCallInviteCancelledEvent","Cancelled","error","message","code","undefined","NotificationTapped","_uuid","_customParameters","_from","_to","NativeEventEmitter","addListener","ScopeCallInvite","_handleNativeCallInviteEvent","event","accept","options","Pending","InvalidStateError","acceptResult","NativeModule","callInvite_accept","then","catch","userInfo","reject","callInvite_reject","isValid","callInvite_isValid","getCallSid","getCustomParameters","getFrom","getState","getTo","sendMessage","content","contentType","messageType","voiceEventSid","call_sendMessage","outgoingCallMessage","OutgoingCallMessage","updateCallerHandle","newHandle","Platform","OS","callInvite_updateCallerHandle","UnsupportedPlatformError","Listener"],"mappings":";;;;;;;AAOA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AASA;;AACA;;AACA;;AACA;;;;AAsMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,UAAN,SAAyBC,0BAAzB,CAAsC;AAC3C;AACF;AACA;AACA;AACA;AACA;;AAEE;AACF;AACA;AACA;AACA;;AAEE;AACF;AACA;;AAEE;AACF;AACA;;AAEE;AACF;AACA;;AAEE;AACF;AACA;;AAGE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACEC,EAAAA,WAAW,CACT;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,OAAR;AAAiBC,IAAAA,gBAAjB;AAAmCC,IAAAA,IAAnC;AAAyCC,IAAAA;AAAzC,GADS,EAETC,KAFS,EAGT;AACA;;AADA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,0DAsCAC,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AAwBC,MAAAA;AAAxB,QAAwC,sCAAoBnC,OAApB,CAA9C;AAEA,UAAMoC,aAAa,GAAG,MAAMlB,qBAAamB,gBAAb,CAC1B,KAAKjC,KADqB,EAE1B6B,OAF0B,EAG1BC,WAH0B,EAI1BC,WAJ0B,CAA5B;AAOA,UAAMG,mBAAmB,GAAG,IAAIC,wCAAJ,CAAwB;AAClDN,MAAAA,OADkD;AAElDC,MAAAA,WAFkD;AAGlDC,MAAAA,WAHkD;AAIlDC,MAAAA;AAJkD,KAAxB,CAA5B;AAOA,WAAOE,mBAAP;AACD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAC0B,QAAlBE,kBAAkB,CAACC,SAAD,EAAmC;AACzD,YAAQC,iBAASC,EAAjB;AACE,WAAK,KAAL;AACE,eAAOzB,qBAAa0B,6BAAb,CACL,KAAKxC,KADA,EAELqC,SAFK,CAAP;;AAIF;AACE,cAAM,IAAII,kDAAJ,CACH,yBAAwBH,iBAASC,EAAG,0CADjC,CAAN;AAPJ;AAWD;;AAvX0C;AA0X7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AAEE;AACF;AACA;MAMcrD,K;;aAAAA,K;AAAAA,IAAAA,K;AAAAA,IAAAA,K;AAAAA,IAAAA,K;AAAAA,IAAAA,K;KAAAA,K,KAAAA,K;;;MA0BAJ,K;;aAAAA,K;AAAAA,IAAAA,K;AAAAA,IAAAA,K;AAAAA,IAAAA,K;AAAAA,IAAAA,K;AAAAA,IAAAA,K;KAAAA,K,KAAAA,K;;;;;4BAoCK4D,Q,KAAAA,Q,eAAAA,Q,iBAAAA,Q;GAvEFzF,U,0BAAAA,U","sourcesContent":["/**\n * Copyright © 2022 Twilio, Inc. All rights reserved. Licensed under the Twilio\n * license.\n *\n * See LICENSE in the project root for license information.\n */\n\nimport { EventEmitter } from 'eventemitter3';\nimport { Call } from './Call';\nimport { NativeEventEmitter, NativeModule, Platform } from './common';\nimport { InvalidStateError } from './error/InvalidStateError';\nimport { TwilioError } from './error/TwilioError';\nimport { UnsupportedPlatformError } from './error/UnsupportedPlatformError';\nimport { constructTwilioError } from './error/utility';\nimport type {\n NativeCallInviteInfo,\n NativeCallInviteEvent,\n NativeCallInviteAcceptedEvent,\n NativeCallInviteCancelledEvent,\n NativeCallInviteMessageReceivedEvent,\n} from './type/CallInvite';\nimport type { CustomParameters, Uuid } from './type/common';\nimport { CallMessage, validateCallMessage } from './CallMessage/CallMessage';\nimport { IncomingCallMessage } from './CallMessage/IncomingCallMessage';\nimport { OutgoingCallMessage } from './CallMessage/OutgoingCallMessage';\nimport { Constants } from './constants';\n\n/**\n * Defines strict typings for all events emitted by {@link (CallInvite:class)\n * | CallInvite objects}.\n *\n * @remarks\n * Note that the `on` function is an alias for the `addListener` function.\n * They share identical functionality and either may be used interchangeably.\n *\n * - See also the {@link (CallInvite:class) | CallInvite class}.\n * - See also the {@link (CallInvite:namespace) | CallInvite namespace}.\n *\n * @public\n */\nexport declare interface CallInvite {\n /**\n * ------------\n * Emit Typings\n * ------------\n */\n\n /** @internal */\n emit(acceptedEvent: CallInvite.Event.Accepted, call: Call): boolean;\n\n /** @internal */\n emit(rejectedEvent: CallInvite.Event.Rejected): boolean;\n\n /** @internal */\n emit(\n cancelledEvent: CallInvite.Event.Cancelled,\n error?: TwilioError\n ): boolean;\n\n /** @internal */\n emit(notificationTappedEvent: CallInvite.Event.NotificationTapped): boolean;\n\n /** @internal */\n emit(\n messageReceivedEvent: CallInvite.Event.MessageReceived,\n incomingCallMessage: IncomingCallMessage\n ): boolean;\n\n /**\n * ----------------\n * Listener Typings\n * ----------------\n */\n\n /**\n * Accepted event. Raised when the call invite has been accepted.\n *\n * @example\n * ```ts\n * voice.on(Voice.Event.CallInvite, (callInvite) => {\n * callInvite.on(CallInvite.Event.Accepted, (call) => {\n * // the call invite was accepted through either the native layer\n * // or the js layer\n * });\n * });\n * ```\n *\n * @remarks\n *\n * @param acceptedEvent - The raised event string.\n * @param listener - A listener function that will be invoked when the event\n * is raised.\n * @returns - The call invite object.\n */\n addListener(\n acceptedEvent: CallInvite.Event.Accepted,\n listener: CallInvite.Listener.Accepted\n ): this;\n /** {@inheritDoc (CallInvite:interface).(addListener:1)} */\n on(\n acceptedEvent: CallInvite.Event.Accepted,\n listener: CallInvite.Listener.Accepted\n ): this;\n\n /**\n * Rejected event. Raised when the call invite has been rejected.\n *\n * @example\n * ```ts\n * voice.on(Voice.Event.CallInvite, (callInvite) => {\n * callInvite.on(CallInvite.Event.Rejected, () => {\n * // the call invite was rejected through either the native layer\n * // or the js layer\n * });\n * });\n * ```\n *\n * @remarks\n *\n * @param rejectedEvent - The raised event string.\n * @param listener - A listener function that will be invoked when the event\n * is raised.\n * @returns - The call invite object.\n */\n addListener(\n rejectedEvent: CallInvite.Event.Rejected,\n listener: CallInvite.Listener.Rejected\n ): this;\n /** {@inheritDoc (CallInvite:interface).(addListener:2)} */\n on(\n rejectedEvent: CallInvite.Event.Rejected,\n listener: CallInvite.Listener.Rejected\n ): this;\n\n /**\n * Cancelled event. Raised when the call invite has been cancelled.\n *\n * @example\n * ```ts\n * voice.on(Voice.Event.CallInvite, (callInvite) => {\n * callInvite.on(CallInvite.Event.Cancelled, (error) => {\n * // the call invite was cancelled\n * });\n * });\n * ```\n *\n * @remarks\n *\n * @param cancelledEvent - The raised event string.\n * @param listener - A listener function that will be invoked when the event\n * is raised.\n * @returns - The call invite object.\n */\n addListener(\n cancelledEvent: CallInvite.Event.Cancelled,\n listener: CallInvite.Listener.Cancelled\n ): this;\n /** {@inheritDoc (CallInvite:interface).(addListener:3)} */\n on(\n cancelledEvent: CallInvite.Event.Cancelled,\n listener: CallInvite.Listener.Cancelled\n ): this;\n\n /**\n * Notification tapped event. Raised when the call invite notification has\n * been tapped.\n *\n * @example\n * ```ts\n * voice.on(Voice.Event.CallInvite, (callInvite) => {\n * callInvite.on(CallInvite.Event.NotificationTapped, () => {\n * // the call invite notification was tapped\n * });\n * });\n * ```\n *\n * @remarks\n * This API is Android specific.\n *\n * @param notificationTappedEvent - The raised event string.\n * @param listener - A listener function that will be invoked when the event\n * is raised.\n * @returns - The call invite object.\n */\n addListener(\n notificationTappedEvent: CallInvite.Event.NotificationTapped,\n listener: CallInvite.Listener.NotificationTapped\n ): this;\n /** {@inheritDoc (CallInvite:interface).(addListener:4)} */\n on(\n notificationTappedEvent: CallInvite.Event.NotificationTapped,\n listener: CallInvite.Listener.NotificationTapped\n ): this;\n\n /**\n * MessageReceived event. Raised when a {@link IncomingCallMessage} is\n * received.\n *\n * @example\n * ```typescript\n * voice.on(Voice.Event.CallInvite, (callInvite) => {\n * callInvite.addListener(CallInvite.Event.MessageReceived, (message) => {\n * // callMessage received\n * });\n * });\n * ```\n *\n * @param messageReceivedEvent - The raised event string.\n * @param listener - A listener function that will be invoked when the event\n * is raised.\n * @returns - The callMessage object\n */\n addListener(\n messageReceivedEvent: CallInvite.Event.MessageReceived,\n listener: CallInvite.Listener.MessageReceived\n ): this;\n /** {@inheritDoc (CallInvite:interface).(addListener:5)} */\n on(\n messageReceivedEvent: CallInvite.Event.MessageReceived,\n listener: CallInvite.Listener.MessageReceived\n ): this;\n}\n\n/**\n * Provides access to information about a call invite, including the call\n * parameters, and exposes functionality to accept or decline a call.\n *\n * @remarks\n *\n * Note that when a `CallInvite` is acted upon (i.e. when\n * {@link (CallInvite:class).accept} or {@link (CallInvite:class).reject} is\n * invoked), then the `CallInvite` is \"settled\".\n *\n * The state of the `CallInvite` is changed from\n * {@link (CallInvite:namespace).State.Pending} to\n * {@link (CallInvite:namespace).State.Accepted} or\n * {@link (CallInvite:namespace).State.Rejected} and the `CallInvite` can no\n * longer be acted upon further.\n *\n * Further action after \"settling\" a `CallInvite` will throw an error.\n *\n * - See the {@link (CallInvite:namespace) | CallInvite namespace} for\n * enumerations and types used by this class.\n *\n * @public\n */\nexport class CallInvite extends EventEmitter {\n /**\n * The current state of the call invite.\n *\n * @remarks\n * See {@link (CallInvite:namespace).State}.\n */\n private _state: CallInvite.State;\n /**\n * The `Uuid` of this call invite. Used to identify calls between the JS and\n * native layer so we can associate events and native functionality between\n * the layers.\n */\n private _uuid: Uuid;\n /**\n * A string representing the SID of this call.\n */\n private _callSid: string;\n /**\n * Call custom parameters.\n */\n private _customParameters: CustomParameters;\n /**\n * Call `from` parameter.\n */\n private _from: string;\n /**\n * Call `to` parameter.\n */\n private _to: string;\n\n /**\n * These objects should not be instantiated by consumers of the SDK. All\n * instances of the `CallInvite` class should be emitted by the SDK.\n *\n * @param nativeCallInviteInfo - A dataobject containing the native\n * information of a call invite.\n * @param state - Mocking options for testing.\n *\n * @internal\n */\n constructor(\n { uuid, callSid, customParameters, from, to }: NativeCallInviteInfo,\n state: CallInvite.State\n ) {\n super();\n\n this._uuid = uuid;\n this._callSid = callSid;\n this._customParameters = { ...customParameters };\n this._from = from;\n this._to = to;\n\n this._state = state;\n\n NativeEventEmitter.addListener(\n Constants.ScopeCallInvite,\n this._handleNativeCallInviteEvent\n );\n }\n\n /**\n * This helper function serves as both a runtime-check error log and a\n * compile-time type-guard. If the switch-case statement below is non-\n * exhaustive, then the type passed to this function will _not_ have type\n * `never`.\n */\n private _handleUnexpectedCallInviteEventType(event: never) {\n throw new TwilioError(\n `Unknown event type \"${(event as any)?.type}\" reached call invite.`\n );\n }\n\n /**\n * This intermediate native call invite event handler acts as a \"gate\", only\n * executing the actual call invite event handler (such as `Accepted`) if\n * this call invite object matches the `Uuid` of the call invite that had an\n * event raised.\n * @param nativeCallInviteEvent - A call invite event directly from the native\n * layer.\n */\n private _handleNativeCallInviteEvent = (\n nativeCallInviteEvent: NativeCallInviteEvent\n ) => {\n if (typeof nativeCallInviteEvent !== 'object') {\n throw new TwilioError(\n `Received a \"${typeof nativeCallInviteEvent}\" native call invite event.`\n );\n }\n\n if (nativeCallInviteEvent === null) {\n throw new TwilioError('Received a null native call invite event.');\n }\n\n if (typeof nativeCallInviteEvent.callSid !== 'string') {\n throw new TwilioError(\n 'Received a native call invite event without a call SID.'\n );\n }\n\n if (nativeCallInviteEvent.callSid !== this._callSid) {\n return;\n }\n\n switch (nativeCallInviteEvent.type) {\n case Constants.CallInviteEventTypeValueAccepted:\n return this._handleCallInviteAccepted(nativeCallInviteEvent);\n case Constants.CallInviteEventTypeValueRejected:\n return this._handleCallInviteRejected();\n case Constants.CallInviteEventTypeValueCancelled:\n return this._handleCallInviteCancelled(nativeCallInviteEvent);\n case Constants.CallInviteEventTypeValueNotificationTapped:\n return this._handleCallInviteNotificationTapped();\n case Constants.CallEventMessageReceived:\n return this._handleMessageReceivedEvent(nativeCallInviteEvent);\n default:\n return this._handleUnexpectedCallInviteEventType(nativeCallInviteEvent);\n }\n };\n\n /**\n * Handler for the {@link (CallInvite:namespace).Event.MessageReceived} event.\n * @param nativeCallEvent - The native call event.\n */\n private _handleMessageReceivedEvent = (\n nativeCallInviteEvent: NativeCallInviteMessageReceivedEvent\n ) => {\n const { callMessage: callMessageInfo } = nativeCallInviteEvent;\n\n const callMessage = new IncomingCallMessage(callMessageInfo);\n\n this.emit(CallInvite.Event.MessageReceived, callMessage);\n };\n\n /**\n * Handle when this call invite is accepted.\n */\n private _handleCallInviteAccepted = ({\n callInvite,\n }: NativeCallInviteAcceptedEvent) => {\n this._state = CallInvite.State.Accepted;\n\n const callInfo = {\n uuid: callInvite.uuid,\n customParameters: callInvite.customParameters,\n sid: callInvite.callSid,\n from: callInvite.from,\n to: callInvite.to,\n };\n\n const call = new Call(callInfo);\n\n this.emit(CallInvite.Event.Accepted, call);\n };\n\n /**\n * Handle when this call invite is rejected.\n */\n private _handleCallInviteRejected = () => {\n this._state = CallInvite.State.Rejected;\n this.emit(CallInvite.Event.Rejected);\n };\n\n /**\n * Handle when a call invite is cancelled.\n */\n private _handleCallInviteCancelled = (\n nativeCallInviteCancelledEvent: NativeCallInviteCancelledEvent\n ) => {\n this._state = CallInvite.State.Cancelled;\n\n const error = nativeCallInviteCancelledEvent.error\n ? constructTwilioError(\n nativeCallInviteCancelledEvent.error.message,\n nativeCallInviteCancelledEvent.error.code\n )\n : undefined;\n\n this.emit(CallInvite.Event.Cancelled, error);\n };\n\n /**\n * Handle when a call invite notification is tapped.\n */\n private _handleCallInviteNotificationTapped = () => {\n this.emit(CallInvite.Event.NotificationTapped);\n };\n\n /**\n * Accept a call invite. Sets the state of this call invite to\n * {@link (CallInvite:namespace).State.Accepted}.\n * @param options - Options to pass to the native layer when accepting the\n * call.\n * @returns\n * - Resolves when a {@link (Call:class) | Call object} associated with this\n * {@link (CallInvite:class)} has been created.\n */\n async accept(options: CallInvite.AcceptOptions = {}): Promise<Call> {\n if (this._state !== CallInvite.State.Pending) {\n throw new InvalidStateError(\n `Call in state \"${this._state}\", ` +\n `expected state \"${CallInvite.State.Pending}\".`\n );\n }\n\n const acceptResult = await NativeModule.callInvite_accept(\n this._uuid,\n options\n )\n .then((callInfo) => {\n return { type: 'ok', callInfo } as const;\n })\n .catch((error) => {\n const code = error.userInfo.code;\n const message = error.userInfo.message;\n return { type: 'err', message, code } as const;\n });\n\n if (acceptResult.type === 'err') {\n throw constructTwilioError(acceptResult.message, acceptResult.code);\n }\n\n return new Call(acceptResult.callInfo);\n }\n\n /**\n * Reject a call invite. Sets the state of this call invite to\n * {@link (CallInvite:namespace).State.Rejected}.\n * @returns\n * - Resolves when the {@link (CallInvite:class)} has been rejected.\n */\n async reject(): Promise<void> {\n if (this._state !== CallInvite.State.Pending) {\n throw new InvalidStateError(\n `Call in state \"${this._state}\", ` +\n `expected state \"${CallInvite.State.Pending}\".`\n );\n }\n\n await NativeModule.callInvite_reject(this._uuid);\n }\n\n /**\n * Check if a `CallInvite` is valid.\n *\n * @returns\n * - TODO\n *\n * @alpha\n */\n isValid(): Promise<boolean> {\n return NativeModule.callInvite_isValid(this._uuid);\n }\n\n /**\n * Get the call SID associated with this `CallInvite` class.\n * @returns - A string representing the call SID.\n */\n getCallSid(): string {\n return this._callSid;\n }\n\n /**\n * Get the custom parameters of the call associated with this `CallInvite`\n * class.\n * @returns - A `Record` of custom parameters.\n */\n getCustomParameters(): CustomParameters {\n return this._customParameters;\n }\n\n /**\n * Get the `from` parameter of the call associated with this `CallInvite`\n * class.\n * @returns - A `string` representing the `from` parameter.\n */\n getFrom(): string {\n return this._from;\n }\n\n /**\n * Get the `state` of the `CallInvite`.\n * @returns - The `state` of this `CallInvite`.\n */\n getState(): CallInvite.State {\n return this._state;\n }\n\n /**\n * Get the `to` parameter of the call associated with this `CallInvite`\n * class.\n * @returns - A `string` representing the `to` parameter.\n */\n getTo(): string {\n return this._to;\n }\n\n /**\n * Send a CallMessage.\n *\n * @example\n * To send a user-defined-message\n * ```typescript\n * const outgoingCallMessage: OutgoingCallMessage = await callInvite.sendMessage({\n * content: { key1: 'This is a messsage from the parent call invite' },\n * contentType: 'application/json',\n * messageType: 'user-defined-message'\n * });\n *\n * outgoingCallMessage.addListener(OutgoingCallMessage.Event.Failure, (error) => {\n * // outgoingCallMessage failed, handle error\n * });\n *\n * outgoingCallMessage.addListener(OutgoingCallMessage.Event.Sent, () => {\n * // outgoingCallMessage sent\n * });\n * ```\n *\n * @param message - The call message to send.\n *\n * @returns\n * A `Promise` that\n * - Resolves with the OutgoingCallMessage object.\n * - Rejects when the message is unable to be sent.\n */\n async sendMessage(message: CallMessage): Promise<OutgoingCallMessage> {\n const { content, contentType, messageType } = validateCallMessage(message);\n\n const voiceEventSid = await NativeModule.call_sendMessage(\n this._uuid,\n content,\n contentType,\n messageType\n );\n\n const outgoingCallMessage = new OutgoingCallMessage({\n content,\n contentType,\n messageType,\n voiceEventSid,\n });\n\n return outgoingCallMessage;\n }\n\n /**\n * Update the caller name displayed in the iOS system incoming call screen.\n *\n * @param newHandle - The new value of the caller's name.\n *\n * @remarks\n * Unsupported platforms:\n * - Android\n *\n * This API is specific to iOS and unavailable in Android. Invoke this method\n * after the incoming call has been reported to CallKit and before the call\n * has been accepted. For example, perform an async request to your app server\n * to fetch the full name of the caller and use this method to replace the\n * default caller name in `from`.\n *\n * @returns\n * - Resolves when the caller name has been updated.\n */\n async updateCallerHandle(newHandle: string): Promise<void> {\n switch (Platform.OS) {\n case 'ios':\n return NativeModule.callInvite_updateCallerHandle(\n this._uuid,\n newHandle\n );\n default:\n throw new UnsupportedPlatformError(\n `Unsupported platform \"${Platform.OS}\". This method is only supported on iOS.`\n );\n }\n }\n}\n\n/**\n * Provides enumerations and types used by a {@link (CallInvite:class)\n * | CallInvite object}.\n *\n * @remarks\n * - See also the {@link (CallInvite:class) | CallInvite class}.\n *\n * @public\n */\nexport namespace CallInvite {\n /**\n * Options to pass to the native layer when accepting the call.\n */\n export interface AcceptOptions {}\n\n /**\n * An enumeration of {@link (CallInvite:class)} states.\n */\n export enum State {\n /**\n * State of a call invite when it has not been acted upon.\n */\n Pending = 'pending',\n\n /**\n * State of a call invite when it has been accepted.\n */\n Accepted = 'accepted',\n\n /**\n * State of a call invite when it has been rejected.\n */\n Rejected = 'rejected',\n\n /**\n * State of a call invite when it has been cancelled.\n */\n Cancelled = 'cancelled',\n }\n\n /**\n * Enumeration of all event strings emitted by {@link (CallInvite:class)}\n * objects.\n */\n export enum Event {\n /**\n * Event string for the `Accepted` event.\n * See {@link (CallInvite:interface).(addListener:1)}.\n */\n Accepted = 'accepted',\n\n /**\n * Event string for the `Rejected` event.\n * See {@link (CallInvite:interface).(addListener:2)}.\n */\n Rejected = 'rejected',\n\n /**\n * Event string for the `Cancelled` event.\n * See {@link (CallInvite:interface).(addListener:3)}.\n */\n Cancelled = 'cancelled',\n\n /**\n * Event string for the `NotificationTapped` event.\n * See {@link (CallInvite:interface).(addListener:4)}.\n */\n NotificationTapped = 'notificationTapped',\n\n /**\n * Event string for the `MessageReceived` event.\n * See {@link (CallInvite:interface).(addListener:5)}\n */\n MessageReceived = 'messageReceived',\n }\n\n /**\n * Listener types for all events emitted by a\n * {@link (CallInvite:class) | Call invite object.}\n */\n export namespace Listener {\n /**\n * Accepted event listener. This should be the function signature of any\n * event listener bound to the {@link (CallInvite:namespace).Event.Accepted}\n * event.\n *\n * @remarks\n * See {@link (CallInvite:interface).(addListener:1)}.\n */\n export type Accepted = (call: Call) => void;\n\n /**\n * Rejected event listener. This should be the function signature of any\n * event listener bound to the {@link (CallInvite:namespace).Event.Rejected}\n * event.\n *\n * @remarks\n * See {@link (CallInvite:interface).(addListener:2)}.\n */\n export type Rejected = () => void;\n\n /**\n * Cancelled event listener. This should be the function signature of any\n * event listener bound to the\n * {@link (CallInvite:namespace).Event.Cancelled} event.\n *\n * @remarks\n * See {@link (CallInvite:interface).(addListener:3)}.\n */\n export type Cancelled = (error?: TwilioError) => void;\n\n /**\n * Rejected event listener. This should be the function signature of any\n * event listener bound to the\n * {@link (CallInvite:namespace).Event.NotificationTapped} event.\n *\n * @remarks\n * See {@link (CallInvite:interface).(addListener:4)}.\n */\n export type NotificationTapped = () => void;\n\n /**\n * CallInviteMessage received event listener. This should be the function signature of\n * any event listener bound to the {@link (CallInvite:namespace).Event.MessageReceived} event.\n *\n * @remarks\n * See {@link (CallInvite:interface).(addListener:5)}.\n */\n export type MessageReceived = (\n incomingCallMessage: IncomingCallMessage\n ) => void;\n }\n}\n"]}
|