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,620 @@
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 { AudioDevice } from './AudioDevice';
9
+ import { Call } from './Call';
10
+ import { CallInvite } from './CallInvite';
11
+ import type { TwilioError } from './error/TwilioError';
12
+ import type { CallKit } from './type/CallKit';
13
+ import type { Uuid } from './type/common';
14
+ /**
15
+ * Defines strict typings for all events emitted by {@link (Voice:class)
16
+ * | Voice objects}.
17
+ *
18
+ * @remarks
19
+ * Note that the `on` function is an alias for the `addListener` function.
20
+ * They share identical functionality and either may be used interchangeably.
21
+ *
22
+ * - See also the {@link (Voice:class) | Voice class}.
23
+ * - See also the {@link (Voice:namespace) | Voice namespace}.
24
+ *
25
+ * @public
26
+ */
27
+ export declare interface Voice {
28
+ /**
29
+ * ------------
30
+ * Emit Typings
31
+ * ------------
32
+ */
33
+ /** @internal */
34
+ emit(voiceEvent: Voice.Event.AudioDevicesUpdated, audioDevices: AudioDevice[], selectedDevice?: AudioDevice): boolean;
35
+ /** @internal */
36
+ emit(voiceEvent: Voice.Event.CallInvite, callInvite: CallInvite): boolean;
37
+ /** @internal */
38
+ emit(voiceEvent: Voice.Event.Error, error: TwilioError): boolean;
39
+ /** @internal */
40
+ emit(voiceEvent: Voice.Event.Registered): boolean;
41
+ /** @internal */
42
+ emit(voiceEvent: Voice.Event.Unregistered): boolean;
43
+ /** @internal */
44
+ emit(voiceEvent: Voice.Event, ...args: any[]): boolean;
45
+ /**
46
+ * ----------------
47
+ * Listener Typings
48
+ * ----------------
49
+ */
50
+ /**
51
+ * Audio devices updated event. Raised when the list of audio devices changes.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * voice.addListener(Voice.Event.AudioDevicesUpdated, () => {
56
+ * // the list of available audio devices has changed and/or the selected
57
+ * // audio device has been changed
58
+ * });
59
+ * ```
60
+ *
61
+ * @param audioDevicesUpdatedEvent - The raised event string.
62
+ * @param listener - A listener function that will be invoked when the event
63
+ * is raised.
64
+ * @returns - The call object.
65
+ */
66
+ addListener(audioDevicesUpdatedEvent: Voice.Event.AudioDevicesUpdated, listener: Voice.Listener.AudioDevicesUpdated): this;
67
+ /** {@inheritDoc (Voice:interface).(addListener:1)} */
68
+ on(audioDevicesUpdatedEvent: Voice.Event.AudioDevicesUpdated, listener: Voice.Listener.AudioDevicesUpdated): this;
69
+ /**
70
+ * Call invite event. Raised when an incoming call invite is received.
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * voice.addListener(Voice.Event.CallInvite, (callInvite: CallInvite) => {
75
+ * // handle the incoming call invite
76
+ * });
77
+ * ```
78
+ *
79
+ * @param callInviteEvent - The raised event string.
80
+ * @param listener - A listener function that will be invoked when the event
81
+ * is raised.
82
+ * @returns - The call object.
83
+ */
84
+ addListener(callInviteEvent: Voice.Event.CallInvite, listener: Voice.Listener.CallInvite): this;
85
+ /** {@inheritDoc (Voice:interface).(addListener:2)} */
86
+ on(callInviteEvent: Voice.Event.CallInvite, listener: Voice.Listener.CallInvite): this;
87
+ /**
88
+ * Error event. Raised when the SDK encounters an error.
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * voice.addListener(Voice.Event.Error, (error: TwilioError.GenericError) => {
93
+ * // handle a generic Voice SDK error
94
+ * });
95
+ * ```
96
+ *
97
+ * @param errorEvent - The raised event string.
98
+ * @param listener - A listener function that will be invoked when the event
99
+ * is raised.
100
+ * @returns - The call object.
101
+ */
102
+ addListener(errorEvent: Voice.Event.Error, listener: Voice.Listener.Error): this;
103
+ /** {@inheritDoc (Voice:interface).(addListener:3)} */
104
+ on(errorEvent: Voice.Event.Error, listener: Voice.Listener.Error): this;
105
+ /**
106
+ * Registered event. Raised when the SDK is registered for incoming calls.
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * voice.addListener(Voice.Event.Registered, () => {
111
+ * // handle successful registration for incoming calls
112
+ * });
113
+ * ```
114
+ *
115
+ * @param registeredEvent - The raised event string.
116
+ * @param listener - A listener function that will be invoked when the event
117
+ * is raised.
118
+ * @returns - The call object.
119
+ */
120
+ addListener(registeredEvent: Voice.Event.Registered, listener: Voice.Listener.Registered): this;
121
+ /** {@inheritDoc (Voice:interface).(addListener:4)} */
122
+ on(registeredEvent: Voice.Event.Registered, listener: Voice.Listener.Registered): this;
123
+ /**
124
+ * Unregistered event. Raised when the SDK is unregistered for incoming calls.
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * voice.addListener(Voice.Event.Unregistered, () => {
129
+ * // handle successful unregistration for incoming calls
130
+ * });
131
+ * ```
132
+ *
133
+ * @param unregisteredEvent - The raised event string.
134
+ * @param listener - A listener function that will be invoked when the event
135
+ * is raised.
136
+ * @returns - The call object.
137
+ */
138
+ addListener(unregisteredEvent: Voice.Event.Unregistered, listener: Voice.Listener.Unregistered): this;
139
+ /** {@inheritDoc (Voice:interface).(addListener:5)} */
140
+ on(unregisteredEvent: Voice.Event.Unregistered, listener: Voice.Listener.Unregistered): this;
141
+ /**
142
+ * Generic event listener typings.
143
+ * @param voiceEvent - The raised event string.
144
+ * @param listener - A listener function that will be invoked when the event
145
+ * is raised.
146
+ * @returns - The call object.
147
+ */
148
+ addListener(voiceEvent: Voice.Event, listener: Voice.Listener.Generic): this;
149
+ /** {@inheritDoc (Voice:interface).(addListener:6)} */
150
+ on(voiceEvent: Voice.Event, listener: Voice.Listener.Generic): this;
151
+ }
152
+ /**
153
+ * Main entry-point of the Voice SDK. Provides access to the entire feature-set
154
+ * of the library.
155
+ *
156
+ * @example
157
+ * Usage:
158
+ * ```
159
+ * const token = '...';
160
+ *
161
+ * const voice = new Voice();
162
+ *
163
+ * voice.on(Voice.Event.CallInvite, (callInvite: CallInvite) => {
164
+ * callInvite.accept();
165
+ * });
166
+ *
167
+ * voice.register(token);
168
+ * ```
169
+ *
170
+ * @remarks
171
+ * - See also the {@link (Voice:namespace).Event} enum for events emitted by
172
+ * `Voice` objects.
173
+ * - See also the {@link (Voice:interface) | Voice interface} for events
174
+ * emitted by this class and associated types.
175
+ * - See also the {@link (Voice:namespace) | Voice namespace} for types and
176
+ * enumerations used by this class.
177
+ *
178
+ * @public
179
+ */
180
+ export declare class Voice extends EventEmitter {
181
+ /**
182
+ * Handlers for native voice events. Set upon construction so we can
183
+ * dynamically bind events to handlers.
184
+ *
185
+ * @privateRemarks
186
+ * This is done by the constructor so this mapping isn't made every time the
187
+ * {@link (Voice:class)._handleNativeEvent} function is invoked.
188
+ */
189
+ private _nativeEventHandler;
190
+ /**
191
+ * Main entry-point of the Voice SDK. Provides access to the entire
192
+ * feature-set of the library.
193
+ */
194
+ constructor();
195
+ /**
196
+ * Connect for devices on Android platforms.
197
+ */
198
+ private _connect_android;
199
+ /**
200
+ * Connect for devices on iOS platforms.
201
+ */
202
+ private _connect_ios;
203
+ /**
204
+ * Intermediary event handler for `Voice`-level events. Ensures that the type
205
+ * of the incoming event is expected and invokes the proper event listener.
206
+ * @param nativeVoiceEvent - A `Voice` event directly from the native layer.
207
+ */
208
+ private _handleNativeEvent;
209
+ /**
210
+ * Call invite handler. Creates a {@link (CallInvite:class)} from the info
211
+ * raised by the native layer and emits it.
212
+ * @param nativeVoiceEvent - A `Voice` event directly from the native layer.
213
+ */
214
+ private _handleCallInvite;
215
+ /**
216
+ * Error event handler. Creates an error from the namespace
217
+ * {@link TwilioErrors} from the info raised by the native layer and emits it.
218
+ * @param nativeVoiceEvent - A `Voice` event directly from the native layer.
219
+ */
220
+ private _handleError;
221
+ /**
222
+ * Registered event handler. Emits a
223
+ * {@link (Voice:namespace).Event.Registered} event.
224
+ */
225
+ private _handleRegistered;
226
+ /**
227
+ * Unregistered event handler. Emits a
228
+ * {@link (Voice:namespace).Event.Unregistered} event.
229
+ */
230
+ private _handleUnregistered;
231
+ /**
232
+ * Audio devices updated event handler. Generates a new list of
233
+ * {@link (AudioDevice:class) | AudioDevice objects} and emits it.
234
+ * @param nativeVoiceEvent - A `Voice` event directly from the native layer.
235
+ */
236
+ private _handleAudioDevicesUpdated;
237
+ /**
238
+ * Create an outgoing call.
239
+ *
240
+ * @remarks
241
+ * Note that the resolution of the returned `Promise` does not imply any call
242
+ * event occurring, such as answered or rejected.
243
+ * The `contactHandle` parameter is only required for iOS apps. Currently the
244
+ * parameter does have any effect on Android apps and can be ignored.
245
+ * `Default Contact` will appear in the iOS call history if the value is empty
246
+ * or not provided.
247
+ *
248
+ * @param token - A Twilio Access Token, usually minted by an
249
+ * authentication-gated endpoint using a Twilio helper library.
250
+ * @param options - Connect options.
251
+ * See {@link (Voice:namespace).ConnectOptions}.
252
+ *
253
+ * @returns
254
+ * A `Promise` that
255
+ * - Resolves with a call when the call is created.
256
+ * - Rejects:
257
+ * * When a call is not able to be created on the native layer.
258
+ * * With an {@link TwilioErrors.InvalidArgumentError} when invalid
259
+ * arguments are passed.
260
+ */
261
+ connect(token: string, { contactHandle, notificationDisplayName, params, }?: Voice.ConnectOptions): Promise<Call>;
262
+ /**
263
+ * Get the version of the native SDK. Note that this is not the version of the
264
+ * React Native SDK, this is the version of the mobile SDK that the RN SDK is
265
+ * utilizing.
266
+ * @returns
267
+ * A `Promise` that
268
+ * - Resolves with a string representing the version of the native SDK.
269
+ */
270
+ getVersion(): Promise<string>;
271
+ /**
272
+ * Get the Device token from the native layer.
273
+ * @returns a Promise that resolves with a string representing the Device
274
+ * token.
275
+ */
276
+ getDeviceToken(): Promise<string>;
277
+ /**
278
+ * Get a list of existing calls, ongoing and pending. This will not return any
279
+ * call that has finished.
280
+ * @returns
281
+ * A `Promise` that
282
+ * - Resolves with a mapping of `Uuid`s to {@link (Call:class)}s.
283
+ */
284
+ getCalls(): Promise<ReadonlyMap<Uuid, Call>>;
285
+ /**
286
+ * Get a list of pending call invites.
287
+ *
288
+ * @remarks
289
+ * This list will not contain any call invites that have been "settled"
290
+ * (answered or rejected).
291
+ *
292
+ * @returns
293
+ * A `Promise` that
294
+ * - Resolves with a mapping of `Uuid`s to {@link (CallInvite:class)}s.
295
+ */
296
+ getCallInvites(): Promise<ReadonlyMap<Uuid, CallInvite>>;
297
+ /**
298
+ * Handle Firebase messages from an out-of-band Firebase messaging service.
299
+ *
300
+ * @remarks
301
+ *
302
+ * Note that this method only works on Android platforms, and will only work
303
+ * when the built-in Firebase messaging service as been opted-out.
304
+ *
305
+ * Unsupported platforms:
306
+ * - iOS
307
+ *
308
+ * @returns
309
+ * A `Promise` that
310
+ * - Resolves with a boolean. This boolean is `true` if the Firebase message
311
+ * was handled properly, `false` otherwise.
312
+ * - Rejects if an error occurred when parsing the Firebase message, or if
313
+ * the app is incorrectly configured. This method will also reject if used
314
+ * on an unsupported platform.
315
+ */
316
+ handleFirebaseMessage(remoteMessage: Record<string, string>): Promise<boolean>;
317
+ /**
318
+ * Register this device for incoming calls.
319
+ * @param token - A Twilio Access Token.
320
+ * @returns
321
+ * A `Promise` that
322
+ * - Resolves when the device has been registered.
323
+ */
324
+ register(token: string): Promise<void>;
325
+ /**
326
+ * Unregister this device for incoming calls.
327
+ * @param token - A Twilio Access Token.
328
+ * @returns
329
+ * A `Promise` that
330
+ * - Resolves when the device has been unregistered.
331
+ */
332
+ unregister(token: string): Promise<void>;
333
+ /**
334
+ * Get audio device information from the native layer.
335
+ * @returns
336
+ * A `Promise` that
337
+ * - Resolves with a list of the native device's audio devices and the
338
+ * currently selected device.
339
+ */
340
+ getAudioDevices(): Promise<{
341
+ audioDevices: AudioDevice[];
342
+ selectedDevice?: AudioDevice;
343
+ }>;
344
+ /**
345
+ * Show the native AV route picker.
346
+ *
347
+ * @remarks
348
+ * Unsupported platforms:
349
+ * - Android
350
+ *
351
+ * This API is specific to iOS and unavailable in Android. If this API is
352
+ * invoked on Android, there will be no operation and the returned `Promise`
353
+ * will immediately resolve with `null`.
354
+ *
355
+ * @returns
356
+ * A `Promise` that
357
+ * - Resolves when the AV Route Picker View is shown.
358
+ */
359
+ showAvRoutePickerView(): Promise<void>;
360
+ /**
361
+ * Initialize a Push Registry instance inside the SDK for handling
362
+ * PushKit device token updates and receiving push notifications.
363
+ *
364
+ * @remarks
365
+ * Unsupported platforms:
366
+ * - Android
367
+ *
368
+ * This API is specific to iOS and unavailable in Android.
369
+ * Use this method if the application does not have an iOS PushKit
370
+ * module and wishes to delegate the event handling to the SDK.
371
+ * Call this method upon launching the app to guarantee that incoming
372
+ * call push notifications will be surfaced to the users, especially when
373
+ * the app is not running in the foreground.
374
+ *
375
+ * @returns
376
+ * A `Promise` that
377
+ * - Resolves when the initialization is done.
378
+ */
379
+ initializePushRegistry(): Promise<void>;
380
+ /**
381
+ * Custom iOS CallKit configuration.
382
+ *
383
+ * @param configuration - iOS CallKit configuration options.
384
+ *
385
+ * @remarks
386
+ * Unsupported platforms:
387
+ * - Android
388
+ *
389
+ * See {@link CallKit} for more information.
390
+ *
391
+ * @returns
392
+ * A `Promise` that
393
+ * - Resolves when the configuration has been applied.
394
+ * - Rejects if the configuration is unable to be applied.
395
+ */
396
+ setCallKitConfiguration(configuration: CallKit.ConfigurationOptions): Promise<void>;
397
+ /**
398
+ * Set the native call contact handle template.
399
+ *
400
+ * This method is used to customize the displayed contact for Android
401
+ * notifications and the contact handle displayed in iOS CallKit UIs.
402
+ *
403
+ * @example
404
+ * ```ts
405
+ * await voice.setIncomingCallContactHandleTemplate('Foo ${DisplayName}');
406
+ * ```
407
+ * If an incoming call is made and there is a Twiml Parameter with key
408
+ * "DisplayName" and value "Bar", then the notification title or CallKit
409
+ * handle will display as "Foo Bar".
410
+ *
411
+ * @example
412
+ * ```ts
413
+ * await voice.setIncomingCallContactHandleTemplate();
414
+ * ```
415
+ * When invoking this method without any parameters, the template will be
416
+ * unset and the default notification and contact handle behavior is restored.
417
+ *
418
+ * @param template - The string to set the notification and contact handle
419
+ * template to. Note that this value is optional, if the method is invoked
420
+ * with an implicit undefined (no parameter) then the template will be unset
421
+ * and the default notification and contact handle behavior will be restored.
422
+ * Empty string values will be considered as the same as passing `undefined`.
423
+ *
424
+ * @returns
425
+ * A `Promise` that
426
+ * - Resolves with `undefined` if the template were set.
427
+ * - Rejects if the template was unable to be set.
428
+ */
429
+ setIncomingCallContactHandleTemplate(template?: string): Promise<void>;
430
+ /**
431
+ * Returns a boolean representing whether or not Android Full Screen
432
+ * notifications are enabled.
433
+ *
434
+ * @remarks
435
+ * Unsupported platforms:
436
+ * - iOS
437
+ *
438
+ * @returns
439
+ * A `Promise` that
440
+ * - Resolves `false` if either of the following is true:
441
+ * - Full Screen Notifications are disabled in your app's configuration.
442
+ * See `docs/disable-full-screen-notifications.md` for more info.
443
+ * - The app was not granted Full Screen Notification permissions by the
444
+ * operating system.
445
+ * - Resolves `true` if none of the above is true.
446
+ * - Rejects if the Android layer encountered an error.
447
+ */
448
+ isFullScreenNotificationEnabled(): Promise<boolean>;
449
+ /**
450
+ * Opens the Android System Settings app to attempt to request Full Screen
451
+ * Notification permissions.
452
+ *
453
+ * @remarks
454
+ * Unsupported platforms:
455
+ * - iOS
456
+ *
457
+ * @returns
458
+ * A `Promise` that
459
+ * - Resolves `void` if the Android System Settings app was opened.
460
+ * - Rejects if the Android system encountered an error while trying to open
461
+ * the System Settings app.
462
+ */
463
+ requestFullScreenNotificationPermission(): Promise<void>;
464
+ }
465
+ /**
466
+ * Provides enumerations and types used by {@link (Voice:class)
467
+ * | Voice objects}.
468
+ *
469
+ * @remarks
470
+ * - See also the {@link (Voice:class) | Voice class}.
471
+ * - See also the {@link (Voice:interface) | Voice interface}.
472
+ *
473
+ * @public
474
+ */
475
+ export declare namespace Voice {
476
+ /**
477
+ * Options to pass to the {@link (Voice:class).connect} method.
478
+ */
479
+ type ConnectOptions = {
480
+ /**
481
+ * Custom parameters to send to the TwiML Application.
482
+ */
483
+ params?: Record<string, string>;
484
+ /**
485
+ * A CallKit display name that will show in the call history as the contact
486
+ * handle.
487
+ *
488
+ * @remarks
489
+ * Unsupported platforms:
490
+ * - Android
491
+ */
492
+ contactHandle?: string;
493
+ /**
494
+ * The display name that will show in the Android notifications. Passing an
495
+ * empty string will be considered the same as if `undefined` were passed.
496
+ *
497
+ * @remarks
498
+ * Unsupported platforms:
499
+ * - iOS
500
+ */
501
+ notificationDisplayName?: string;
502
+ };
503
+ /**
504
+ * Enumeration of all event strings emitted by {@link (Voice:class)} objects.
505
+ */
506
+ enum Event {
507
+ /**
508
+ * Raised when there is a change in available audio devices.
509
+ *
510
+ * @remarks
511
+ *
512
+ * See {@link (Voice:interface).(addListener:1)
513
+ * | Voice.addListener(AudioDevicesUpdated)}.
514
+ */
515
+ 'AudioDevicesUpdated' = "audioDevicesUpdated",
516
+ /**
517
+ * Raised when there is an incoming call invite.
518
+ *
519
+ * @remarks
520
+ *
521
+ * See {@link (Voice:interface).(addListener:2)
522
+ * | Voice.addListener(CallInvite)}.
523
+ */
524
+ 'CallInvite' = "callInvite",
525
+ /**
526
+ * Raised when the SDK encounters an error.
527
+ *
528
+ * @remarks
529
+ *
530
+ * See {@link (Voice:interface).(addListener:3)
531
+ * | Voice.addListener(Error)}.
532
+ */
533
+ 'Error' = "error",
534
+ /**
535
+ * Raised when the SDK is registered for incoming calls.
536
+ *
537
+ * @remarks
538
+ *
539
+ * See {@link (Voice:interface).(addListener:4)
540
+ * | Voice.addListener(Registered)}.
541
+ */
542
+ 'Registered' = "registered",
543
+ /**
544
+ * Raised when the SDK is unregistered for incoming calls.
545
+ *
546
+ * @remarks
547
+ *
548
+ * See {@link (Voice:interface).(addListener:5)
549
+ * | Voice.addListener(Unregistered)}.
550
+ */
551
+ 'Unregistered' = "unregistered"
552
+ }
553
+ /**
554
+ * Listener types for all events emitted by a {@link (Voice:class)
555
+ * | Voice object.}
556
+ */
557
+ namespace Listener {
558
+ /**
559
+ * Audio devices updated event listener. This should be the function
560
+ * signature of an event listener bound to the
561
+ * {@link (Voice:namespace).Event.AudioDevicesUpdated} event.
562
+ *
563
+ * @remarks
564
+ *
565
+ * See {@link (Voice:interface).(addListener:1)}.
566
+ */
567
+ type AudioDevicesUpdated = (audioDevices: AudioDevice[], selectedDevice?: AudioDevice) => void;
568
+ /**
569
+ * Call invite event listener. This should be the function signature of an
570
+ * event listener bound to the
571
+ * {@link (Voice:namespace).Event.CallInvite} event.
572
+ *
573
+ * @remarks
574
+ *
575
+ * See {@link (Voice:interface).(addListener:2)}.
576
+ */
577
+ type CallInvite = (callInvite: CallInvite) => void;
578
+ /**
579
+ * Error event listener. This should be the function signature of an event
580
+ * listener bound to the
581
+ * {@link (Voice:namespace).Event.Error} event.
582
+ *
583
+ * @remarks
584
+ *
585
+ * See {@link (Voice:interface).(addListener:3)}.
586
+ *
587
+ * See {@link TwilioErrors} for all error classes.
588
+ */
589
+ type Error = (error: TwilioError) => void;
590
+ /**
591
+ * Registered event listener. This should be the function signature of an
592
+ * event listener bound to the
593
+ * {@link (Voice:namespace).Event.Registered} event.
594
+ *
595
+ * @remarks
596
+ *
597
+ * See {@link (Voice:interface).(addListener:4)}.
598
+ */
599
+ type Registered = () => void;
600
+ /**
601
+ * Unregistered event listener. This should be the function signature of an
602
+ * event listener bound to the
603
+ * {@link (Voice:namespace).Event.Unregistered} event.
604
+ *
605
+ * @remarks
606
+ *
607
+ * See {@link (Voice:interface).(addListener:5)}.
608
+ */
609
+ type Unregistered = () => void;
610
+ /**
611
+ * Generic event listener. This should be the function signature of any
612
+ * event listener bound to any voice event.
613
+ *
614
+ * @remarks
615
+ *
616
+ * See {@link (Voice:interface).(addListener:6)}.
617
+ */
618
+ type Generic = (...args: any[]) => void;
619
+ }
620
+ }
@@ -0,0 +1,11 @@
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 * as ReactNative from 'react-native';
8
+ import type { TwilioVoiceReactNative as TwilioVoiceReactNativeType } from './type/NativeModule';
9
+ export declare const NativeModule: TwilioVoiceReactNativeType;
10
+ export declare const NativeEventEmitter: ReactNative.NativeEventEmitter;
11
+ export declare const Platform: ReactNative.Platform;