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.
Files changed (227) hide show
  1. package/LICENSE +206 -0
  2. package/README.md +179 -0
  3. package/android/build.gradle +113 -0
  4. package/android/gradle.properties +29 -0
  5. package/android/src/main/AndroidManifest.xml +30 -0
  6. package/android/src/main/java/com/twiliovoicereactnative/AudioSwitchManager.java +141 -0
  7. package/android/src/main/java/com/twiliovoicereactnative/CallListenerProxy.java +186 -0
  8. package/android/src/main/java/com/twiliovoicereactnative/CallMessageListenerProxy.java +103 -0
  9. package/android/src/main/java/com/twiliovoicereactnative/CallRecordDatabase.java +183 -0
  10. package/android/src/main/java/com/twiliovoicereactnative/CommonConstants.java +195 -0
  11. package/android/src/main/java/com/twiliovoicereactnative/ConfigurationProperties.java +41 -0
  12. package/android/src/main/java/com/twiliovoicereactnative/Constants.java +23 -0
  13. package/android/src/main/java/com/twiliovoicereactnative/ExpoActivityLifecycleListener.java +27 -0
  14. package/android/src/main/java/com/twiliovoicereactnative/ExpoApplicationLifecycleListener.java +14 -0
  15. package/android/src/main/java/com/twiliovoicereactnative/ExpoModule.kt +36 -0
  16. package/android/src/main/java/com/twiliovoicereactnative/ExpoPackage.java +20 -0
  17. package/android/src/main/java/com/twiliovoicereactnative/JSEventEmitter.java +98 -0
  18. package/android/src/main/java/com/twiliovoicereactnative/MediaPlayerManager.java +58 -0
  19. package/android/src/main/java/com/twiliovoicereactnative/NotificationUtility.java +363 -0
  20. package/android/src/main/java/com/twiliovoicereactnative/ReactNativeArgumentsSerializer.java +276 -0
  21. package/android/src/main/java/com/twiliovoicereactnative/SDKLog.java +74 -0
  22. package/android/src/main/java/com/twiliovoicereactnative/StatsListenerProxy.java +178 -0
  23. package/android/src/main/java/com/twiliovoicereactnative/TwilioVoiceReactNativeModule.java +778 -0
  24. package/android/src/main/java/com/twiliovoicereactnative/TwilioVoiceReactNativePackage.java +28 -0
  25. package/android/src/main/java/com/twiliovoicereactnative/VoiceActivityProxy.java +101 -0
  26. package/android/src/main/java/com/twiliovoicereactnative/VoiceApplicationProxy.java +133 -0
  27. package/android/src/main/java/com/twiliovoicereactnative/VoiceFirebaseMessagingService.java +88 -0
  28. package/android/src/main/java/com/twiliovoicereactnative/VoiceService.java +403 -0
  29. package/android/src/main/res/drawable/answered_call_small_icon.png +0 -0
  30. package/android/src/main/res/drawable/ic_launcher_round.png +0 -0
  31. package/android/src/main/res/drawable/ic_launcher_sdk.png +0 -0
  32. package/android/src/main/res/drawable/incoming_call_small_icon.png +0 -0
  33. package/android/src/main/res/drawable/outgoing_call_small_icon.png +0 -0
  34. package/android/src/main/res/raw/disconnect.wav +0 -0
  35. package/android/src/main/res/raw/incoming.wav +0 -0
  36. package/android/src/main/res/raw/outgoing.wav +0 -0
  37. package/android/src/main/res/raw/ringtone.wav +0 -0
  38. package/android/src/main/res/raw/silent.wav +0 -0
  39. package/android/src/main/res/values/colors.xml +11 -0
  40. package/android/src/main/res/values/config.xml +5 -0
  41. package/android/src/main/res/values/dimens.xml +7 -0
  42. package/android/src/main/res/values/strings.xml +25 -0
  43. package/android/src/main/res/values/styles.xml +10 -0
  44. package/android/src/main/res/values-night/colors.xml +11 -0
  45. package/expo-config-plugin/android.js +191 -0
  46. package/expo-config-plugin/ios.js +22 -0
  47. package/expo-module.config.json +6 -0
  48. package/ios/TwilioVoicePushRegistry.h +19 -0
  49. package/ios/TwilioVoicePushRegistry.m +72 -0
  50. package/ios/TwilioVoiceReactNative+CallInvite.m +56 -0
  51. package/ios/TwilioVoiceReactNative+CallKit.m +533 -0
  52. package/ios/TwilioVoiceReactNative+CallMessage.m +81 -0
  53. package/ios/TwilioVoiceReactNative.h +74 -0
  54. package/ios/TwilioVoiceReactNative.m +1046 -0
  55. package/ios/TwilioVoiceReactNative.xcodeproj/project.pbxproj +328 -0
  56. package/ios/TwilioVoiceReactNativeConstants.h +200 -0
  57. package/ios/Utilities/TwilioVoiceStatsReport.h +175 -0
  58. package/lib/commonjs/AudioDevice.js +101 -0
  59. package/lib/commonjs/AudioDevice.js.map +1 -0
  60. package/lib/commonjs/Call.js +765 -0
  61. package/lib/commonjs/Call.js.map +1 -0
  62. package/lib/commonjs/CallInvite.js +452 -0
  63. package/lib/commonjs/CallInvite.js.map +1 -0
  64. package/lib/commonjs/CallMessage/CallMessage.js +54 -0
  65. package/lib/commonjs/CallMessage/CallMessage.js.map +1 -0
  66. package/lib/commonjs/CallMessage/IncomingCallMessage.js +120 -0
  67. package/lib/commonjs/CallMessage/IncomingCallMessage.js.map +1 -0
  68. package/lib/commonjs/CallMessage/OutgoingCallMessage.js +148 -0
  69. package/lib/commonjs/CallMessage/OutgoingCallMessage.js.map +1 -0
  70. package/lib/commonjs/ExpoModule.js +69 -0
  71. package/lib/commonjs/ExpoModule.js.map +1 -0
  72. package/lib/commonjs/Voice.js +611 -0
  73. package/lib/commonjs/Voice.js.map +1 -0
  74. package/lib/commonjs/common.js +26 -0
  75. package/lib/commonjs/common.js.map +1 -0
  76. package/lib/commonjs/constants.js +158 -0
  77. package/lib/commonjs/constants.js.map +1 -0
  78. package/lib/commonjs/error/InvalidArgumentError.js +32 -0
  79. package/lib/commonjs/error/InvalidArgumentError.js.map +1 -0
  80. package/lib/commonjs/error/InvalidStateError.js +33 -0
  81. package/lib/commonjs/error/InvalidStateError.js.map +1 -0
  82. package/lib/commonjs/error/TwilioError.js +38 -0
  83. package/lib/commonjs/error/TwilioError.js.map +1 -0
  84. package/lib/commonjs/error/UnsupportedPlatformError.js +33 -0
  85. package/lib/commonjs/error/UnsupportedPlatformError.js.map +1 -0
  86. package/lib/commonjs/error/generated.js +2343 -0
  87. package/lib/commonjs/error/generated.js.map +1 -0
  88. package/lib/commonjs/error/index.js +112 -0
  89. package/lib/commonjs/error/index.js.map +1 -0
  90. package/lib/commonjs/error/utility.js +37 -0
  91. package/lib/commonjs/error/utility.js.map +1 -0
  92. package/lib/commonjs/index.js +95 -0
  93. package/lib/commonjs/index.js.map +1 -0
  94. package/lib/commonjs/type/AudioDevice.js +6 -0
  95. package/lib/commonjs/type/AudioDevice.js.map +1 -0
  96. package/lib/commonjs/type/Call.js +6 -0
  97. package/lib/commonjs/type/Call.js.map +1 -0
  98. package/lib/commonjs/type/CallInvite.js +6 -0
  99. package/lib/commonjs/type/CallInvite.js.map +1 -0
  100. package/lib/commonjs/type/CallKit.js +30 -0
  101. package/lib/commonjs/type/CallKit.js.map +1 -0
  102. package/lib/commonjs/type/CallMessage.js +6 -0
  103. package/lib/commonjs/type/CallMessage.js.map +1 -0
  104. package/lib/commonjs/type/Error.js +6 -0
  105. package/lib/commonjs/type/Error.js.map +1 -0
  106. package/lib/commonjs/type/NativeModule.js +6 -0
  107. package/lib/commonjs/type/NativeModule.js.map +1 -0
  108. package/lib/commonjs/type/RTCStats.js +29 -0
  109. package/lib/commonjs/type/RTCStats.js.map +1 -0
  110. package/lib/commonjs/type/Voice.js +6 -0
  111. package/lib/commonjs/type/Voice.js.map +1 -0
  112. package/lib/commonjs/type/common.js +2 -0
  113. package/lib/commonjs/type/common.js.map +1 -0
  114. package/lib/module/AudioDevice.js +97 -0
  115. package/lib/module/AudioDevice.js.map +1 -0
  116. package/lib/module/Call.js +766 -0
  117. package/lib/module/Call.js.map +1 -0
  118. package/lib/module/CallInvite.js +450 -0
  119. package/lib/module/CallInvite.js.map +1 -0
  120. package/lib/module/CallMessage/CallMessage.js +51 -0
  121. package/lib/module/CallMessage/CallMessage.js.map +1 -0
  122. package/lib/module/CallMessage/IncomingCallMessage.js +116 -0
  123. package/lib/module/CallMessage/IncomingCallMessage.js.map +1 -0
  124. package/lib/module/CallMessage/OutgoingCallMessage.js +154 -0
  125. package/lib/module/CallMessage/OutgoingCallMessage.js.map +1 -0
  126. package/lib/module/ExpoModule.js +58 -0
  127. package/lib/module/ExpoModule.js.map +1 -0
  128. package/lib/module/Voice.js +598 -0
  129. package/lib/module/Voice.js.map +1 -0
  130. package/lib/module/common.js +11 -0
  131. package/lib/module/common.js.map +1 -0
  132. package/lib/module/constants.js +151 -0
  133. package/lib/module/constants.js.map +1 -0
  134. package/lib/module/error/InvalidArgumentError.js +23 -0
  135. package/lib/module/error/InvalidArgumentError.js.map +1 -0
  136. package/lib/module/error/InvalidStateError.js +24 -0
  137. package/lib/module/error/InvalidStateError.js.map +1 -0
  138. package/lib/module/error/TwilioError.js +29 -0
  139. package/lib/module/error/TwilioError.js.map +1 -0
  140. package/lib/module/error/UnsupportedPlatformError.js +24 -0
  141. package/lib/module/error/UnsupportedPlatformError.js.map +1 -0
  142. package/lib/module/error/generated.js +2315 -0
  143. package/lib/module/error/generated.js.map +1 -0
  144. package/lib/module/error/index.js +6 -0
  145. package/lib/module/error/index.js.map +1 -0
  146. package/lib/module/error/utility.js +27 -0
  147. package/lib/module/error/utility.js.map +1 -0
  148. package/lib/module/index.js +23 -0
  149. package/lib/module/index.js.map +1 -0
  150. package/lib/module/type/AudioDevice.js +2 -0
  151. package/lib/module/type/AudioDevice.js.map +1 -0
  152. package/lib/module/type/Call.js +2 -0
  153. package/lib/module/type/Call.js.map +1 -0
  154. package/lib/module/type/CallInvite.js +2 -0
  155. package/lib/module/type/CallInvite.js.map +1 -0
  156. package/lib/module/type/CallKit.js +22 -0
  157. package/lib/module/type/CallKit.js.map +1 -0
  158. package/lib/module/type/CallMessage.js +2 -0
  159. package/lib/module/type/CallMessage.js.map +1 -0
  160. package/lib/module/type/Error.js +2 -0
  161. package/lib/module/type/Error.js.map +1 -0
  162. package/lib/module/type/NativeModule.js +2 -0
  163. package/lib/module/type/NativeModule.js.map +1 -0
  164. package/lib/module/type/RTCStats.js +21 -0
  165. package/lib/module/type/RTCStats.js.map +1 -0
  166. package/lib/module/type/Voice.js +2 -0
  167. package/lib/module/type/Voice.js.map +1 -0
  168. package/lib/module/type/common.js +2 -0
  169. package/lib/module/type/common.js.map +1 -0
  170. package/lib/typescript/AudioDevice.d.ts +74 -0
  171. package/lib/typescript/Call.d.ts +874 -0
  172. package/lib/typescript/CallInvite.d.ts +484 -0
  173. package/lib/typescript/CallMessage/CallMessage.d.ts +53 -0
  174. package/lib/typescript/CallMessage/IncomingCallMessage.d.ts +75 -0
  175. package/lib/typescript/CallMessage/OutgoingCallMessage.d.ts +198 -0
  176. package/lib/typescript/ExpoModule.d.ts +13 -0
  177. package/lib/typescript/Voice.d.ts +620 -0
  178. package/lib/typescript/common.d.ts +11 -0
  179. package/lib/typescript/constants.d.ts +148 -0
  180. package/lib/typescript/error/InvalidArgumentError.d.ts +11 -0
  181. package/lib/typescript/error/InvalidStateError.d.ts +12 -0
  182. package/lib/typescript/error/TwilioError.d.ts +14 -0
  183. package/lib/typescript/error/UnsupportedPlatformError.d.ts +12 -0
  184. package/lib/typescript/error/generated.d.ts +1558 -0
  185. package/lib/typescript/error/index.d.ts +5 -0
  186. package/lib/typescript/error/utility.d.ts +12 -0
  187. package/lib/typescript/index.d.ts +18 -0
  188. package/lib/typescript/type/AudioDevice.d.ts +15 -0
  189. package/lib/typescript/type/Call.d.ts +59 -0
  190. package/lib/typescript/type/CallInvite.d.ts +40 -0
  191. package/lib/typescript/type/CallKit.d.ts +60 -0
  192. package/lib/typescript/type/CallMessage.d.ts +20 -0
  193. package/lib/typescript/type/Error.d.ts +9 -0
  194. package/lib/typescript/type/NativeModule.d.ts +59 -0
  195. package/lib/typescript/type/RTCStats.d.ts +91 -0
  196. package/lib/typescript/type/Voice.d.ts +16 -0
  197. package/lib/typescript/type/common.d.ts +15 -0
  198. package/package.json +167 -0
  199. package/src/AudioDevice.tsx +88 -0
  200. package/src/Call.tsx +1343 -0
  201. package/src/CallInvite.tsx +757 -0
  202. package/src/CallMessage/CallMessage.ts +83 -0
  203. package/src/CallMessage/IncomingCallMessage.ts +104 -0
  204. package/src/CallMessage/OutgoingCallMessage.ts +308 -0
  205. package/src/ExpoModule.ts +59 -0
  206. package/src/Voice.tsx +1010 -0
  207. package/src/common.ts +16 -0
  208. package/src/constants.ts +193 -0
  209. package/src/error/InvalidArgumentError.ts +19 -0
  210. package/src/error/InvalidStateError.ts +19 -0
  211. package/src/error/TwilioError.ts +22 -0
  212. package/src/error/UnsupportedPlatformError.ts +19 -0
  213. package/src/error/generated.ts +2277 -0
  214. package/src/error/index.ts +18 -0
  215. package/src/error/utility.ts +36 -0
  216. package/src/index.tsx +24 -0
  217. package/src/type/AudioDevice.ts +18 -0
  218. package/src/type/Call.ts +102 -0
  219. package/src/type/CallInvite.ts +59 -0
  220. package/src/type/CallKit.ts +61 -0
  221. package/src/type/CallMessage.ts +31 -0
  222. package/src/type/Error.ts +11 -0
  223. package/src/type/NativeModule.ts +93 -0
  224. package/src/type/RTCStats.ts +99 -0
  225. package/src/type/Voice.ts +31 -0
  226. package/src/type/common.ts +16 -0
  227. package/twilio-voice-react-native.podspec +22 -0
@@ -0,0 +1,484 @@
1
+ /**
2
+ * Copyright © 2022 Twilio, Inc. All rights reserved. Licensed under the Twilio
3
+ * license.
4
+ *
5
+ * See LICENSE in the project root for license information.
6
+ */
7
+ import { EventEmitter } from 'eventemitter3';
8
+ import { Call } from './Call';
9
+ import { TwilioError } from './error/TwilioError';
10
+ import type { NativeCallInviteInfo } from './type/CallInvite';
11
+ import type { CustomParameters } from './type/common';
12
+ import { CallMessage } from './CallMessage/CallMessage';
13
+ import { IncomingCallMessage } from './CallMessage/IncomingCallMessage';
14
+ import { OutgoingCallMessage } from './CallMessage/OutgoingCallMessage';
15
+ /**
16
+ * Defines strict typings for all events emitted by {@link (CallInvite:class)
17
+ * | CallInvite objects}.
18
+ *
19
+ * @remarks
20
+ * Note that the `on` function is an alias for the `addListener` function.
21
+ * They share identical functionality and either may be used interchangeably.
22
+ *
23
+ * - See also the {@link (CallInvite:class) | CallInvite class}.
24
+ * - See also the {@link (CallInvite:namespace) | CallInvite namespace}.
25
+ *
26
+ * @public
27
+ */
28
+ export declare interface CallInvite {
29
+ /**
30
+ * ------------
31
+ * Emit Typings
32
+ * ------------
33
+ */
34
+ /** @internal */
35
+ emit(acceptedEvent: CallInvite.Event.Accepted, call: Call): boolean;
36
+ /** @internal */
37
+ emit(rejectedEvent: CallInvite.Event.Rejected): boolean;
38
+ /** @internal */
39
+ emit(cancelledEvent: CallInvite.Event.Cancelled, error?: TwilioError): boolean;
40
+ /** @internal */
41
+ emit(notificationTappedEvent: CallInvite.Event.NotificationTapped): boolean;
42
+ /** @internal */
43
+ emit(messageReceivedEvent: CallInvite.Event.MessageReceived, incomingCallMessage: IncomingCallMessage): boolean;
44
+ /**
45
+ * ----------------
46
+ * Listener Typings
47
+ * ----------------
48
+ */
49
+ /**
50
+ * Accepted event. Raised when the call invite has been accepted.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * voice.on(Voice.Event.CallInvite, (callInvite) => {
55
+ * callInvite.on(CallInvite.Event.Accepted, (call) => {
56
+ * // the call invite was accepted through either the native layer
57
+ * // or the js layer
58
+ * });
59
+ * });
60
+ * ```
61
+ *
62
+ * @remarks
63
+ *
64
+ * @param acceptedEvent - The raised event string.
65
+ * @param listener - A listener function that will be invoked when the event
66
+ * is raised.
67
+ * @returns - The call invite object.
68
+ */
69
+ addListener(acceptedEvent: CallInvite.Event.Accepted, listener: CallInvite.Listener.Accepted): this;
70
+ /** {@inheritDoc (CallInvite:interface).(addListener:1)} */
71
+ on(acceptedEvent: CallInvite.Event.Accepted, listener: CallInvite.Listener.Accepted): this;
72
+ /**
73
+ * Rejected event. Raised when the call invite has been rejected.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * voice.on(Voice.Event.CallInvite, (callInvite) => {
78
+ * callInvite.on(CallInvite.Event.Rejected, () => {
79
+ * // the call invite was rejected through either the native layer
80
+ * // or the js layer
81
+ * });
82
+ * });
83
+ * ```
84
+ *
85
+ * @remarks
86
+ *
87
+ * @param rejectedEvent - The raised event string.
88
+ * @param listener - A listener function that will be invoked when the event
89
+ * is raised.
90
+ * @returns - The call invite object.
91
+ */
92
+ addListener(rejectedEvent: CallInvite.Event.Rejected, listener: CallInvite.Listener.Rejected): this;
93
+ /** {@inheritDoc (CallInvite:interface).(addListener:2)} */
94
+ on(rejectedEvent: CallInvite.Event.Rejected, listener: CallInvite.Listener.Rejected): this;
95
+ /**
96
+ * Cancelled event. Raised when the call invite has been cancelled.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * voice.on(Voice.Event.CallInvite, (callInvite) => {
101
+ * callInvite.on(CallInvite.Event.Cancelled, (error) => {
102
+ * // the call invite was cancelled
103
+ * });
104
+ * });
105
+ * ```
106
+ *
107
+ * @remarks
108
+ *
109
+ * @param cancelledEvent - The raised event string.
110
+ * @param listener - A listener function that will be invoked when the event
111
+ * is raised.
112
+ * @returns - The call invite object.
113
+ */
114
+ addListener(cancelledEvent: CallInvite.Event.Cancelled, listener: CallInvite.Listener.Cancelled): this;
115
+ /** {@inheritDoc (CallInvite:interface).(addListener:3)} */
116
+ on(cancelledEvent: CallInvite.Event.Cancelled, listener: CallInvite.Listener.Cancelled): this;
117
+ /**
118
+ * Notification tapped event. Raised when the call invite notification has
119
+ * been tapped.
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * voice.on(Voice.Event.CallInvite, (callInvite) => {
124
+ * callInvite.on(CallInvite.Event.NotificationTapped, () => {
125
+ * // the call invite notification was tapped
126
+ * });
127
+ * });
128
+ * ```
129
+ *
130
+ * @remarks
131
+ * This API is Android specific.
132
+ *
133
+ * @param notificationTappedEvent - The raised event string.
134
+ * @param listener - A listener function that will be invoked when the event
135
+ * is raised.
136
+ * @returns - The call invite object.
137
+ */
138
+ addListener(notificationTappedEvent: CallInvite.Event.NotificationTapped, listener: CallInvite.Listener.NotificationTapped): this;
139
+ /** {@inheritDoc (CallInvite:interface).(addListener:4)} */
140
+ on(notificationTappedEvent: CallInvite.Event.NotificationTapped, listener: CallInvite.Listener.NotificationTapped): this;
141
+ /**
142
+ * MessageReceived event. Raised when a {@link IncomingCallMessage} is
143
+ * received.
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * voice.on(Voice.Event.CallInvite, (callInvite) => {
148
+ * callInvite.addListener(CallInvite.Event.MessageReceived, (message) => {
149
+ * // callMessage received
150
+ * });
151
+ * });
152
+ * ```
153
+ *
154
+ * @param messageReceivedEvent - The raised event string.
155
+ * @param listener - A listener function that will be invoked when the event
156
+ * is raised.
157
+ * @returns - The callMessage object
158
+ */
159
+ addListener(messageReceivedEvent: CallInvite.Event.MessageReceived, listener: CallInvite.Listener.MessageReceived): this;
160
+ /** {@inheritDoc (CallInvite:interface).(addListener:5)} */
161
+ on(messageReceivedEvent: CallInvite.Event.MessageReceived, listener: CallInvite.Listener.MessageReceived): this;
162
+ }
163
+ /**
164
+ * Provides access to information about a call invite, including the call
165
+ * parameters, and exposes functionality to accept or decline a call.
166
+ *
167
+ * @remarks
168
+ *
169
+ * Note that when a `CallInvite` is acted upon (i.e. when
170
+ * {@link (CallInvite:class).accept} or {@link (CallInvite:class).reject} is
171
+ * invoked), then the `CallInvite` is "settled".
172
+ *
173
+ * The state of the `CallInvite` is changed from
174
+ * {@link (CallInvite:namespace).State.Pending} to
175
+ * {@link (CallInvite:namespace).State.Accepted} or
176
+ * {@link (CallInvite:namespace).State.Rejected} and the `CallInvite` can no
177
+ * longer be acted upon further.
178
+ *
179
+ * Further action after "settling" a `CallInvite` will throw an error.
180
+ *
181
+ * - See the {@link (CallInvite:namespace) | CallInvite namespace} for
182
+ * enumerations and types used by this class.
183
+ *
184
+ * @public
185
+ */
186
+ export declare class CallInvite extends EventEmitter {
187
+ /**
188
+ * The current state of the call invite.
189
+ *
190
+ * @remarks
191
+ * See {@link (CallInvite:namespace).State}.
192
+ */
193
+ private _state;
194
+ /**
195
+ * The `Uuid` of this call invite. Used to identify calls between the JS and
196
+ * native layer so we can associate events and native functionality between
197
+ * the layers.
198
+ */
199
+ private _uuid;
200
+ /**
201
+ * A string representing the SID of this call.
202
+ */
203
+ private _callSid;
204
+ /**
205
+ * Call custom parameters.
206
+ */
207
+ private _customParameters;
208
+ /**
209
+ * Call `from` parameter.
210
+ */
211
+ private _from;
212
+ /**
213
+ * Call `to` parameter.
214
+ */
215
+ private _to;
216
+ /**
217
+ * These objects should not be instantiated by consumers of the SDK. All
218
+ * instances of the `CallInvite` class should be emitted by the SDK.
219
+ *
220
+ * @param nativeCallInviteInfo - A dataobject containing the native
221
+ * information of a call invite.
222
+ * @param state - Mocking options for testing.
223
+ *
224
+ * @internal
225
+ */
226
+ constructor({ uuid, callSid, customParameters, from, to }: NativeCallInviteInfo, state: CallInvite.State);
227
+ /**
228
+ * This helper function serves as both a runtime-check error log and a
229
+ * compile-time type-guard. If the switch-case statement below is non-
230
+ * exhaustive, then the type passed to this function will _not_ have type
231
+ * `never`.
232
+ */
233
+ private _handleUnexpectedCallInviteEventType;
234
+ /**
235
+ * This intermediate native call invite event handler acts as a "gate", only
236
+ * executing the actual call invite event handler (such as `Accepted`) if
237
+ * this call invite object matches the `Uuid` of the call invite that had an
238
+ * event raised.
239
+ * @param nativeCallInviteEvent - A call invite event directly from the native
240
+ * layer.
241
+ */
242
+ private _handleNativeCallInviteEvent;
243
+ /**
244
+ * Handler for the {@link (CallInvite:namespace).Event.MessageReceived} event.
245
+ * @param nativeCallEvent - The native call event.
246
+ */
247
+ private _handleMessageReceivedEvent;
248
+ /**
249
+ * Handle when this call invite is accepted.
250
+ */
251
+ private _handleCallInviteAccepted;
252
+ /**
253
+ * Handle when this call invite is rejected.
254
+ */
255
+ private _handleCallInviteRejected;
256
+ /**
257
+ * Handle when a call invite is cancelled.
258
+ */
259
+ private _handleCallInviteCancelled;
260
+ /**
261
+ * Handle when a call invite notification is tapped.
262
+ */
263
+ private _handleCallInviteNotificationTapped;
264
+ /**
265
+ * Accept a call invite. Sets the state of this call invite to
266
+ * {@link (CallInvite:namespace).State.Accepted}.
267
+ * @param options - Options to pass to the native layer when accepting the
268
+ * call.
269
+ * @returns
270
+ * - Resolves when a {@link (Call:class) | Call object} associated with this
271
+ * {@link (CallInvite:class)} has been created.
272
+ */
273
+ accept(options?: CallInvite.AcceptOptions): Promise<Call>;
274
+ /**
275
+ * Reject a call invite. Sets the state of this call invite to
276
+ * {@link (CallInvite:namespace).State.Rejected}.
277
+ * @returns
278
+ * - Resolves when the {@link (CallInvite:class)} has been rejected.
279
+ */
280
+ reject(): Promise<void>;
281
+ /**
282
+ * Check if a `CallInvite` is valid.
283
+ *
284
+ * @returns
285
+ * - TODO
286
+ *
287
+ * @alpha
288
+ */
289
+ isValid(): Promise<boolean>;
290
+ /**
291
+ * Get the call SID associated with this `CallInvite` class.
292
+ * @returns - A string representing the call SID.
293
+ */
294
+ getCallSid(): string;
295
+ /**
296
+ * Get the custom parameters of the call associated with this `CallInvite`
297
+ * class.
298
+ * @returns - A `Record` of custom parameters.
299
+ */
300
+ getCustomParameters(): CustomParameters;
301
+ /**
302
+ * Get the `from` parameter of the call associated with this `CallInvite`
303
+ * class.
304
+ * @returns - A `string` representing the `from` parameter.
305
+ */
306
+ getFrom(): string;
307
+ /**
308
+ * Get the `state` of the `CallInvite`.
309
+ * @returns - The `state` of this `CallInvite`.
310
+ */
311
+ getState(): CallInvite.State;
312
+ /**
313
+ * Get the `to` parameter of the call associated with this `CallInvite`
314
+ * class.
315
+ * @returns - A `string` representing the `to` parameter.
316
+ */
317
+ getTo(): string;
318
+ /**
319
+ * Send a CallMessage.
320
+ *
321
+ * @example
322
+ * To send a user-defined-message
323
+ * ```typescript
324
+ * const outgoingCallMessage: OutgoingCallMessage = await callInvite.sendMessage({
325
+ * content: { key1: 'This is a messsage from the parent call invite' },
326
+ * contentType: 'application/json',
327
+ * messageType: 'user-defined-message'
328
+ * });
329
+ *
330
+ * outgoingCallMessage.addListener(OutgoingCallMessage.Event.Failure, (error) => {
331
+ * // outgoingCallMessage failed, handle error
332
+ * });
333
+ *
334
+ * outgoingCallMessage.addListener(OutgoingCallMessage.Event.Sent, () => {
335
+ * // outgoingCallMessage sent
336
+ * });
337
+ * ```
338
+ *
339
+ * @param message - The call message to send.
340
+ *
341
+ * @returns
342
+ * A `Promise` that
343
+ * - Resolves with the OutgoingCallMessage object.
344
+ * - Rejects when the message is unable to be sent.
345
+ */
346
+ sendMessage(message: CallMessage): Promise<OutgoingCallMessage>;
347
+ /**
348
+ * Update the caller name displayed in the iOS system incoming call screen.
349
+ *
350
+ * @param newHandle - The new value of the caller's name.
351
+ *
352
+ * @remarks
353
+ * Unsupported platforms:
354
+ * - Android
355
+ *
356
+ * This API is specific to iOS and unavailable in Android. Invoke this method
357
+ * after the incoming call has been reported to CallKit and before the call
358
+ * has been accepted. For example, perform an async request to your app server
359
+ * to fetch the full name of the caller and use this method to replace the
360
+ * default caller name in `from`.
361
+ *
362
+ * @returns
363
+ * - Resolves when the caller name has been updated.
364
+ */
365
+ updateCallerHandle(newHandle: string): Promise<void>;
366
+ }
367
+ /**
368
+ * Provides enumerations and types used by a {@link (CallInvite:class)
369
+ * | CallInvite object}.
370
+ *
371
+ * @remarks
372
+ * - See also the {@link (CallInvite:class) | CallInvite class}.
373
+ *
374
+ * @public
375
+ */
376
+ export declare namespace CallInvite {
377
+ /**
378
+ * Options to pass to the native layer when accepting the call.
379
+ */
380
+ interface AcceptOptions {
381
+ }
382
+ /**
383
+ * An enumeration of {@link (CallInvite:class)} states.
384
+ */
385
+ enum State {
386
+ /**
387
+ * State of a call invite when it has not been acted upon.
388
+ */
389
+ Pending = "pending",
390
+ /**
391
+ * State of a call invite when it has been accepted.
392
+ */
393
+ Accepted = "accepted",
394
+ /**
395
+ * State of a call invite when it has been rejected.
396
+ */
397
+ Rejected = "rejected",
398
+ /**
399
+ * State of a call invite when it has been cancelled.
400
+ */
401
+ Cancelled = "cancelled"
402
+ }
403
+ /**
404
+ * Enumeration of all event strings emitted by {@link (CallInvite:class)}
405
+ * objects.
406
+ */
407
+ enum Event {
408
+ /**
409
+ * Event string for the `Accepted` event.
410
+ * See {@link (CallInvite:interface).(addListener:1)}.
411
+ */
412
+ Accepted = "accepted",
413
+ /**
414
+ * Event string for the `Rejected` event.
415
+ * See {@link (CallInvite:interface).(addListener:2)}.
416
+ */
417
+ Rejected = "rejected",
418
+ /**
419
+ * Event string for the `Cancelled` event.
420
+ * See {@link (CallInvite:interface).(addListener:3)}.
421
+ */
422
+ Cancelled = "cancelled",
423
+ /**
424
+ * Event string for the `NotificationTapped` event.
425
+ * See {@link (CallInvite:interface).(addListener:4)}.
426
+ */
427
+ NotificationTapped = "notificationTapped",
428
+ /**
429
+ * Event string for the `MessageReceived` event.
430
+ * See {@link (CallInvite:interface).(addListener:5)}
431
+ */
432
+ MessageReceived = "messageReceived"
433
+ }
434
+ /**
435
+ * Listener types for all events emitted by a
436
+ * {@link (CallInvite:class) | Call invite object.}
437
+ */
438
+ namespace Listener {
439
+ /**
440
+ * Accepted event listener. This should be the function signature of any
441
+ * event listener bound to the {@link (CallInvite:namespace).Event.Accepted}
442
+ * event.
443
+ *
444
+ * @remarks
445
+ * See {@link (CallInvite:interface).(addListener:1)}.
446
+ */
447
+ type Accepted = (call: Call) => void;
448
+ /**
449
+ * Rejected event listener. This should be the function signature of any
450
+ * event listener bound to the {@link (CallInvite:namespace).Event.Rejected}
451
+ * event.
452
+ *
453
+ * @remarks
454
+ * See {@link (CallInvite:interface).(addListener:2)}.
455
+ */
456
+ type Rejected = () => void;
457
+ /**
458
+ * Cancelled event listener. This should be the function signature of any
459
+ * event listener bound to the
460
+ * {@link (CallInvite:namespace).Event.Cancelled} event.
461
+ *
462
+ * @remarks
463
+ * See {@link (CallInvite:interface).(addListener:3)}.
464
+ */
465
+ type Cancelled = (error?: TwilioError) => void;
466
+ /**
467
+ * Rejected event listener. This should be the function signature of any
468
+ * event listener bound to the
469
+ * {@link (CallInvite:namespace).Event.NotificationTapped} event.
470
+ *
471
+ * @remarks
472
+ * See {@link (CallInvite:interface).(addListener:4)}.
473
+ */
474
+ type NotificationTapped = () => void;
475
+ /**
476
+ * CallInviteMessage received event listener. This should be the function signature of
477
+ * any event listener bound to the {@link (CallInvite:namespace).Event.MessageReceived} event.
478
+ *
479
+ * @remarks
480
+ * See {@link (CallInvite:interface).(addListener:5)}.
481
+ */
482
+ type MessageReceived = (incomingCallMessage: IncomingCallMessage) => void;
483
+ }
484
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Copyright © 2022 Twilio, Inc. All rights reserved. Licensed under the Twilio
3
+ * license.
4
+ *
5
+ * See LICENSE in the project root for license information.
6
+ */
7
+ /**
8
+ * The constituent values of a Call Message.
9
+ *
10
+ * @public
11
+ */
12
+ export interface CallMessage {
13
+ /**
14
+ * The content of the message. This value should match the content type
15
+ * parameter.
16
+ *
17
+ * See {@link CallMessage.contentType} for more information.
18
+ */
19
+ content: any;
20
+ /**
21
+ * The content type of the message. This value should accurately describe
22
+ * the content of the message. The following values are accepted:
23
+ *
24
+ * - "application/json"
25
+ *
26
+ * If no value is defined, then the default value of "application/json" will
27
+ * be used.
28
+ *
29
+ * If the `contentType` of the message is "application/json", the content
30
+ * of the message may be a JS object.
31
+ */
32
+ contentType?: string;
33
+ /**
34
+ * The message type. The following values are accepted:
35
+ *
36
+ * - "user-defined-message"
37
+ */
38
+ messageType: string;
39
+ }
40
+ /**
41
+ * Parse CallMessage values. Used when constructing a CallMessage from the
42
+ * native layer, or by the Call and CallInvite classes when sending a
43
+ * CallMessage.
44
+ *
45
+ * @param message the CallMessage details.
46
+ *
47
+ * @internal
48
+ */
49
+ export declare function validateCallMessage(message: CallMessage): {
50
+ content: string;
51
+ contentType: string;
52
+ messageType: string;
53
+ };
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Copyright © 2022 Twilio, Inc. All rights reserved. Licensed under the Twilio
3
+ * license.
4
+ *
5
+ * See LICENSE in the project root for license information.
6
+ */
7
+ import { EventEmitter } from 'eventemitter3';
8
+ import type { NativeCallMessageInfo } from '../type/CallMessage';
9
+ /**
10
+ * CallMessage API is in beta.
11
+ *
12
+ * Provides access to information about a CallMessage, including the call
13
+ * message content, content type, message type, and voice event SID.
14
+ *
15
+ * @public
16
+ */
17
+ export declare class IncomingCallMessage extends EventEmitter {
18
+ /**
19
+ * The content of the message which should match the contentType parameter.
20
+ */
21
+ private _content;
22
+ /**
23
+ * The MIME type of the content.
24
+ */
25
+ private _contentType;
26
+ /**
27
+ * Message type
28
+ */
29
+ private _messageType;
30
+ /**
31
+ * An autogenerated ID that uniquely identifies this message.
32
+ * This is not required when sending a message from the SDK as this is
33
+ * autogenerated.
34
+ * The ID will be available after the message is sent, or immediately when a
35
+ * message is received.
36
+ */
37
+ private _voiceEventSid?;
38
+ /**
39
+ * Constructor for the {@link IncomingCallMessage} class. This should not be
40
+ * invoked by third-party code.
41
+ *
42
+ * @param NativeCallMessageInfo - An object containing all of the data from
43
+ * the native layer necessary to fully describe a call message, as well as
44
+ * invoke native functionality for the call message.
45
+ *
46
+ * @internal
47
+ */
48
+ constructor(callMessageInfo: NativeCallMessageInfo);
49
+ /**
50
+ * {@inheritdoc CallMessage.content}
51
+ *
52
+ * @returns the content of the call message.
53
+ */
54
+ getContent(): any;
55
+ /**
56
+ * {@inheritdoc CallMessage.contentType}
57
+ *
58
+ * @returns the content type of the call message.
59
+ */
60
+ getContentType(): string;
61
+ /**
62
+ * {@inheritdoc CallMessage.messageType}
63
+ *
64
+ * @returns the message type of the call message.
65
+ */
66
+ getMessageType(): string;
67
+ /**
68
+ * Get the message SID.
69
+ * @returns
70
+ * - A string representing the message SID.
71
+ * - `undefined` if the call information has not yet been received from the
72
+ * native layer.
73
+ */
74
+ getSid(): string | undefined;
75
+ }