voice-react-native-sdk 1.6.2-fork.4 → 1.6.2-fork.41
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/android/build.gradle +7 -22
- package/android/src/main/java/com/twiliovoicereactnative/ExpoActivityLifecycleListener.java +13 -1
- package/android/src/main/java/com/twiliovoicereactnative/ExpoModule.kt +2 -24
- package/android/src/main/java/com/twiliovoicereactnative/VoiceService.java +49 -10
- package/expo-config-plugin/ios.js +1 -1
- package/expo-module.config.json +1 -1
- package/package.json +1 -1
- package/lib/commonjs/ExpoModule.js +0 -69
- package/lib/commonjs/ExpoModule.js.map +0 -1
- package/lib/module/ExpoModule.js +0 -58
- package/lib/module/ExpoModule.js.map +0 -1
- package/lib/typescript/ExpoModule.d.ts +0 -13
- package/src/ExpoModule.ts +0 -59
package/android/build.gradle
CHANGED
|
@@ -25,6 +25,7 @@ buildscript {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
apply plugin: 'com.android.library'
|
|
28
|
+
apply plugin: 'kotlin-android'
|
|
28
29
|
|
|
29
30
|
def safeExtGet(prop, fallback) {
|
|
30
31
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
@@ -58,27 +59,6 @@ android {
|
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
// Explicit task dependencies to prevent Gradle conflicts
|
|
62
|
-
// Handle both possible naming conventions that might be generated
|
|
63
|
-
tasks.matching { it.name == 'packageDebugResources' }.configureEach {
|
|
64
|
-
dependsOn tasks.matching { it.name == 'generateDebugResValues' }
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
tasks.matching { it.name == 'packageReleaseResources' }.configureEach {
|
|
68
|
-
dependsOn tasks.matching { it.name == 'generateReleaseResValues' }
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Alternative approach - configure all resource tasks
|
|
72
|
-
afterEvaluate {
|
|
73
|
-
tasks.matching { it.name.contains('packageDebugResources') }.configureEach {
|
|
74
|
-
dependsOn tasks.matching { it.name.contains('generateDebugResValues') }
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
tasks.matching { it.name.contains('packageReleaseResources') }.configureEach {
|
|
78
|
-
dependsOn tasks.matching { it.name.contains('generateReleaseResValues') }
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
62
|
repositories {
|
|
83
63
|
google()
|
|
84
64
|
mavenCentral()
|
|
@@ -95,8 +75,13 @@ dependencies {
|
|
|
95
75
|
implementation "androidx.core:core:${versions.androidxCore}"
|
|
96
76
|
implementation "androidx.lifecycle:lifecycle-extensions:${versions.androidxLifecycle}"
|
|
97
77
|
implementation "com.google.firebase:firebase-messaging:${versions.firebaseMessaging}"
|
|
98
|
-
|
|
78
|
+
|
|
79
|
+
// October 2025: I had to use a fork of the audioswitch library so we are aligned with the LiveKit SDK which uses this forked version. Else I was getting build conflicts.
|
|
80
|
+
//implementation "com.twilio:audioswitch:${versions.audioSwitch}"
|
|
81
|
+
implementation 'com.github.davidliu:audioswitch:89582c47c9a04c62f90aa5e57251af4800a62c9a'
|
|
82
|
+
|
|
99
83
|
implementation 'com.google.android.material:material:1.1.0'
|
|
84
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}"
|
|
100
85
|
implementation project(':expo-modules-core')
|
|
101
86
|
|
|
102
87
|
constraints {
|
|
@@ -10,7 +10,19 @@ public class ExpoActivityLifecycleListener implements ReactActivityLifecycleList
|
|
|
10
10
|
|
|
11
11
|
@Override
|
|
12
12
|
public void onCreate(Activity activity, Bundle savedInstanceState) {
|
|
13
|
-
|
|
13
|
+
// Create a PermissionsRationaleNotifier implementation
|
|
14
|
+
VoiceActivityProxy.PermissionsRationaleNotifier notifier = new VoiceActivityProxy.PermissionsRationaleNotifier() {
|
|
15
|
+
@Override
|
|
16
|
+
public void displayRationale(String permission) {
|
|
17
|
+
// Log the permission rationale for debugging
|
|
18
|
+
SDKLog logger = new SDKLog(ExpoActivityLifecycleListener.class);
|
|
19
|
+
logger.debug("Permission rationale needed for: " + permission);
|
|
20
|
+
// You can add additional logic here to show a dialog or notification
|
|
21
|
+
// to the user explaining why the permission is needed
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
this.voiceActivityProxy = new VoiceActivityProxy(activity, notifier);
|
|
14
26
|
this.voiceActivityProxy.onCreate(savedInstanceState);
|
|
15
27
|
}
|
|
16
28
|
|
|
@@ -2,35 +2,13 @@ package com.twiliovoicereactnative
|
|
|
2
2
|
|
|
3
3
|
import expo.modules.kotlin.modules.Module
|
|
4
4
|
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
-
import com.twilio.voice.ConnectOptions
|
|
6
|
-
import java.util.UUID
|
|
7
5
|
|
|
8
6
|
class ExpoModule : Module() {
|
|
9
7
|
private val log = SDKLog(this.javaClass)
|
|
10
8
|
|
|
11
9
|
override fun definition() = ModuleDefinition {
|
|
12
|
-
Name("
|
|
10
|
+
Name("TwilioVoiceExpo")
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
val context = appContext.reactContext ?: return@Function
|
|
16
|
-
|
|
17
|
-
val connectOptions = ConnectOptions.Builder(accessToken).build()
|
|
18
|
-
val uuid = UUID.randomUUID()
|
|
19
|
-
val callListenerProxy = CallListenerProxy(uuid, context)
|
|
20
|
-
|
|
21
|
-
val callRecord = CallRecordDatabase.CallRecord(
|
|
22
|
-
uuid,
|
|
23
|
-
VoiceApplicationProxy.getVoiceServiceApi().connect(
|
|
24
|
-
connectOptions,
|
|
25
|
-
callListenerProxy
|
|
26
|
-
),
|
|
27
|
-
"Callee", // provide a mechanism for determining the name of the callee
|
|
28
|
-
HashMap(), // provide a mechanism for passing custom TwiML parameters
|
|
29
|
-
CallRecord.Direction.OUTGOING,
|
|
30
|
-
"Display Name" // provide a mechanism for determining the notification display name of the callee
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
VoiceApplicationProxy.getCallRecordDatabase().add(callRecord)
|
|
34
|
-
}
|
|
12
|
+
// For some reason I still need to have an empty module for things to work.
|
|
35
13
|
}
|
|
36
14
|
}
|
|
@@ -105,33 +105,65 @@ public class VoiceService extends Service {
|
|
|
105
105
|
if (null != intent) {
|
|
106
106
|
switch (Objects.requireNonNull(intent.getAction())) {
|
|
107
107
|
case ACTION_INCOMING_CALL:
|
|
108
|
-
|
|
108
|
+
final CallRecordDatabase.CallRecord callRecord = getCallRecord(Objects.requireNonNull(getMessageUUID(intent)));
|
|
109
|
+
if (null == callRecord) {
|
|
110
|
+
return START_NOT_STICKY;
|
|
111
|
+
}
|
|
112
|
+
incomingCall(callRecord);
|
|
109
113
|
break;
|
|
110
114
|
case ACTION_ACCEPT_CALL:
|
|
111
115
|
try {
|
|
112
|
-
|
|
116
|
+
final CallRecordDatabase.CallRecord callRecord = getCallRecord(Objects.requireNonNull(getMessageUUID(intent)));
|
|
117
|
+
if (null == callRecord) {
|
|
118
|
+
return START_NOT_STICKY;
|
|
119
|
+
}
|
|
120
|
+
acceptCall(callRecord);
|
|
113
121
|
} catch (SecurityException e) {
|
|
114
122
|
sendPermissionsError();
|
|
115
123
|
logger.warning(e, "Cannot accept call, lacking necessary permissions");
|
|
116
124
|
}
|
|
117
125
|
break;
|
|
118
126
|
case ACTION_REJECT_CALL:
|
|
119
|
-
|
|
127
|
+
final CallRecordDatabase.CallRecord callRecord = getCallRecord(Objects.requireNonNull(getMessageUUID(intent)));
|
|
128
|
+
if (null == callRecord) {
|
|
129
|
+
return START_NOT_STICKY;
|
|
130
|
+
}
|
|
131
|
+
rejectCall(callRecord);
|
|
120
132
|
break;
|
|
121
133
|
case ACTION_CANCEL_CALL:
|
|
122
|
-
|
|
134
|
+
final CallRecordDatabase.CallRecord callRecord = getCallRecord(Objects.requireNonNull(getMessageUUID(intent)));
|
|
135
|
+
if (null == callRecord) {
|
|
136
|
+
return START_NOT_STICKY;
|
|
137
|
+
}
|
|
138
|
+
cancelCall(callRecord);
|
|
123
139
|
break;
|
|
124
140
|
case ACTION_CALL_DISCONNECT:
|
|
125
|
-
|
|
141
|
+
final CallRecordDatabase.CallRecord callRecord = getCallRecord(Objects.requireNonNull(getMessageUUID(intent)));
|
|
142
|
+
if (null == callRecord) {
|
|
143
|
+
return START_NOT_STICKY;
|
|
144
|
+
}
|
|
145
|
+
disconnect(callRecord);
|
|
126
146
|
break;
|
|
127
147
|
case ACTION_RAISE_OUTGOING_CALL_NOTIFICATION:
|
|
128
|
-
|
|
148
|
+
final CallRecordDatabase.CallRecord callRecord = getCallRecord(Objects.requireNonNull(getMessageUUID(intent)));
|
|
149
|
+
if (null == callRecord) {
|
|
150
|
+
return START_NOT_STICKY;
|
|
151
|
+
}
|
|
152
|
+
raiseOutgoingCallNotification(callRecord);
|
|
129
153
|
break;
|
|
130
154
|
case ACTION_CANCEL_ACTIVE_CALL_NOTIFICATION:
|
|
131
|
-
|
|
155
|
+
final CallRecordDatabase.CallRecord callRecord = getCallRecord(Objects.requireNonNull(getMessageUUID(intent)));
|
|
156
|
+
if (null == callRecord) {
|
|
157
|
+
return START_NOT_STICKY;
|
|
158
|
+
}
|
|
159
|
+
cancelActiveCallNotification(callRecord);
|
|
132
160
|
break;
|
|
133
161
|
case ACTION_FOREGROUND_AND_DEPRIORITIZE_INCOMING_CALL_NOTIFICATION:
|
|
134
|
-
|
|
162
|
+
final CallRecordDatabase.CallRecord callRecord = getCallRecord(Objects.requireNonNull(getMessageUUID(intent)));
|
|
163
|
+
if (null == callRecord) {
|
|
164
|
+
return START_NOT_STICKY;
|
|
165
|
+
}
|
|
166
|
+
foregroundAndDeprioritizeIncomingCallNotification(callRecord);
|
|
135
167
|
getCallRecord(Objects.requireNonNull(getMessageUUID(intent))));
|
|
136
168
|
break;
|
|
137
169
|
case ACTION_PUSH_APP_TO_FOREGROUND:
|
|
@@ -329,7 +361,8 @@ public class VoiceService extends Service {
|
|
|
329
361
|
createOrReplaceNotification(callRecord.getNotificationId(), notification);
|
|
330
362
|
|
|
331
363
|
// stop active sound (if any)
|
|
332
|
-
|
|
364
|
+
// 11-14-25: We can keep the sound playing to indicate that the call is still pending pickup.
|
|
365
|
+
//VoiceApplicationProxy.getMediaPlayerManager().stop();
|
|
333
366
|
|
|
334
367
|
// notify JS layer
|
|
335
368
|
sendJSEvent(
|
|
@@ -387,7 +420,13 @@ public class VoiceService extends Service {
|
|
|
387
420
|
return (UUID)intent.getSerializableExtra(Constants.MSG_KEY_UUID);
|
|
388
421
|
}
|
|
389
422
|
private static CallRecordDatabase.CallRecord getCallRecord(final UUID uuid) {
|
|
390
|
-
return Objects.requireNonNull(getCallRecordDatabase().get(new CallRecordDatabase.CallRecord(uuid)));
|
|
423
|
+
//return Objects.requireNonNull(getCallRecordDatabase().get(new CallRecordDatabase.CallRecord(uuid)));
|
|
424
|
+
final CallRecordDatabase.CallRecord callRecord = getCallRecordDatabase().get(new CallRecordDatabase.CallRecord(uuid));
|
|
425
|
+
if (null == callRecord) {
|
|
426
|
+
logger.warning("No call record found");
|
|
427
|
+
return null;
|
|
428
|
+
}
|
|
429
|
+
return callRecord;
|
|
391
430
|
}
|
|
392
431
|
private static void sendJSEvent(@NonNull String scope, @NonNull WritableMap event) {
|
|
393
432
|
getJSEventEmitter().sendEvent(scope, event);
|
|
@@ -12,7 +12,7 @@ function withTwilioVoiceIOS(config) {
|
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
config = withEntitlementsPlist(config, (configuration) => {
|
|
15
|
-
configuration.modResults['aps-environment'] =
|
|
15
|
+
configuration.modResults['aps-environment'] = 'development';
|
|
16
16
|
return configuration;
|
|
17
17
|
});
|
|
18
18
|
|
package/expo-module.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.ExpoModule = void 0;
|
|
7
|
-
|
|
8
|
-
var _common = require("./common");
|
|
9
|
-
|
|
10
|
-
var _expoModulesCore = require("expo-modules-core");
|
|
11
|
-
|
|
12
|
-
var _Call = require("./Call");
|
|
13
|
-
|
|
14
|
-
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; }
|
|
15
|
-
|
|
16
|
-
class ExpoNativeModule {
|
|
17
|
-
constructor() {
|
|
18
|
-
_defineProperty(this, "androidExpoNativeModule", _common.Platform.OS === 'android' ? (() => {
|
|
19
|
-
try {
|
|
20
|
-
return (0, _expoModulesCore.requireNativeModule)('TwilioVoiceExpo');
|
|
21
|
-
} catch (e) {
|
|
22
|
-
console.warn('TwilioVoiceExpo native module not found');
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
})() : null);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async voice_connect(accessToken, options = {}) {
|
|
29
|
-
const {
|
|
30
|
-
params = {},
|
|
31
|
-
customParameters = {}
|
|
32
|
-
} = options;
|
|
33
|
-
let info;
|
|
34
|
-
|
|
35
|
-
if (_common.Platform.OS === 'android' && this.androidExpoNativeModule) {
|
|
36
|
-
info = await this.androidExpoNativeModule.voice_connect(accessToken, params, customParameters);
|
|
37
|
-
} else if (_common.Platform.OS === 'ios') {
|
|
38
|
-
info = await _common.NativeModule.voice_connect_ios(accessToken, params, // @ts-ignore
|
|
39
|
-
customParameters);
|
|
40
|
-
} else {
|
|
41
|
-
throw new Error('Unsupported platform');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return new _Call.Call(info);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async disconnect() {
|
|
48
|
-
var _NativeModule$voice_d;
|
|
49
|
-
|
|
50
|
-
if (_common.Platform.OS === 'android' && this.androidExpoNativeModule) {
|
|
51
|
-
var _this$androidExpoNati, _this$androidExpoNati2;
|
|
52
|
-
|
|
53
|
-
return (_this$androidExpoNati = (_this$androidExpoNati2 = this.androidExpoNativeModule).voice_disconnect) === null || _this$androidExpoNati === void 0 ? void 0 : _this$androidExpoNati.call(_this$androidExpoNati2);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return (_NativeModule$voice_d = _common.NativeModule.voice_disconnect_ios) === null || _NativeModule$voice_d === void 0 ? void 0 : _NativeModule$voice_d.call(_common.NativeModule);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
isExpoEnvironment() {
|
|
60
|
-
return _common.Platform.OS === 'android';
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const ExpoModule = new ExpoNativeModule();
|
|
66
|
-
exports.ExpoModule = ExpoModule;
|
|
67
|
-
var _default = ExpoModule;
|
|
68
|
-
exports.default = _default;
|
|
69
|
-
//# sourceMappingURL=ExpoModule.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["ExpoModule.ts"],"names":["ExpoNativeModule","Platform","OS","e","console","warn","voice_connect","accessToken","options","params","customParameters","info","androidExpoNativeModule","NativeModule","voice_connect_ios","Error","Call","disconnect","voice_disconnect","voice_disconnect_ios","isExpoEnvironment","ExpoModule"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAQA,MAAMA,gBAAN,CAAuB;AAAA;AAAA,qDAEnBC,iBAASC,EAAT,KAAgB,SAAhB,GACI,CAAC,MAAM;AACL,UAAI;AACF,eAAO,0CAAoB,iBAApB,CAAP;AACD,OAFD,CAEE,OAAOC,CAAP,EAAU;AACVC,QAAAA,OAAO,CAACC,IAAR,CAAa,yCAAb;AACA,eAAO,IAAP;AACD;AACF,KAPD,GADJ,GASI,IAXe;AAAA;;AAaF,QAAbC,aAAa,CAACC,WAAD,EAAsBC,OAAuB,GAAG,EAAhD,EAAoD;AACrE,UAAM;AAAEC,MAAAA,MAAM,GAAG,EAAX;AAAeC,MAAAA,gBAAgB,GAAG;AAAlC,QAAyCF,OAA/C;AACA,QAAIG,IAAJ;;AACA,QAAIV,iBAASC,EAAT,KAAgB,SAAhB,IAA6B,KAAKU,uBAAtC,EAA+D;AAC7DD,MAAAA,IAAI,GAAG,MAAM,KAAKC,uBAAL,CAA6BN,aAA7B,CACXC,WADW,EAEXE,MAFW,EAGXC,gBAHW,CAAb;AAKD,KAND,MAMO,IAAIT,iBAASC,EAAT,KAAgB,KAApB,EAA2B;AAChCS,MAAAA,IAAI,GAAG,MAAME,qBAAaC,iBAAb,CACXP,WADW,EAEXE,MAFW,EAGX;AACAC,MAAAA,gBAJW,CAAb;AAMD,KAPM,MAOA;AACL,YAAM,IAAIK,KAAJ,CAAU,sBAAV,CAAN;AACD;;AACD,WAAO,IAAIC,UAAJ,CAASL,IAAT,CAAP;AACD;;AAEe,QAAVM,UAAU,GAAG;AAAA;;AACjB,QAAIhB,iBAASC,EAAT,KAAgB,SAAhB,IAA6B,KAAKU,uBAAtC,EAA+D;AAAA;;AAC7D,sCAAO,+BAAKA,uBAAL,EAA6BM,gBAApC,0DAAO,kDAAP;AACD;;AACD,oCAAOL,qBAAaM,oBAApB,0DAAO,gDAAP;AACD;;AAEDC,EAAAA,iBAAiB,GAAY;AAC3B,WAAOnB,iBAASC,EAAT,KAAgB,SAAvB;AACD;;AA5CoB;;AA+ChB,MAAMmB,UAAU,GAAG,IAAIrB,gBAAJ,EAAnB;;eACQqB,U","sourcesContent":["import { NativeModule, Platform } from './common';\nimport { requireNativeModule } from 'expo-modules-core';\nimport { Call } from './Call';\nimport type { NativeCallInfo } from './type/Call';\n\ninterface ConnectOptions {\n params?: Record<string, any>;\n customParameters?: Record<string, any>;\n}\n\nclass ExpoNativeModule {\n private androidExpoNativeModule =\n Platform.OS === 'android'\n ? (() => {\n try {\n return requireNativeModule('TwilioVoiceExpo');\n } catch (e) {\n console.warn('TwilioVoiceExpo native module not found');\n return null;\n }\n })()\n : null;\n\n async voice_connect(accessToken: string, options: ConnectOptions = {}) {\n const { params = {}, customParameters = {} } = options;\n let info: NativeCallInfo;\n if (Platform.OS === 'android' && this.androidExpoNativeModule) {\n info = await this.androidExpoNativeModule.voice_connect(\n accessToken,\n params,\n customParameters\n );\n } else if (Platform.OS === 'ios') {\n info = await NativeModule.voice_connect_ios(\n accessToken,\n params,\n // @ts-ignore\n customParameters\n );\n } else {\n throw new Error('Unsupported platform');\n }\n return new Call(info);\n }\n\n async disconnect() {\n if (Platform.OS === 'android' && this.androidExpoNativeModule) {\n return this.androidExpoNativeModule.voice_disconnect?.();\n }\n return NativeModule.voice_disconnect_ios?.();\n }\n\n isExpoEnvironment(): boolean {\n return Platform.OS === 'android';\n }\n}\n\nexport const ExpoModule = new ExpoNativeModule();\nexport default ExpoModule;\n"]}
|
package/lib/module/ExpoModule.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
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; }
|
|
2
|
-
|
|
3
|
-
import { NativeModule, Platform } from './common';
|
|
4
|
-
import { requireNativeModule } from 'expo-modules-core';
|
|
5
|
-
import { Call } from './Call';
|
|
6
|
-
|
|
7
|
-
class ExpoNativeModule {
|
|
8
|
-
constructor() {
|
|
9
|
-
_defineProperty(this, "androidExpoNativeModule", Platform.OS === 'android' ? (() => {
|
|
10
|
-
try {
|
|
11
|
-
return requireNativeModule('TwilioVoiceExpo');
|
|
12
|
-
} catch (e) {
|
|
13
|
-
console.warn('TwilioVoiceExpo native module not found');
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
})() : null);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async voice_connect(accessToken, options = {}) {
|
|
20
|
-
const {
|
|
21
|
-
params = {},
|
|
22
|
-
customParameters = {}
|
|
23
|
-
} = options;
|
|
24
|
-
let info;
|
|
25
|
-
|
|
26
|
-
if (Platform.OS === 'android' && this.androidExpoNativeModule) {
|
|
27
|
-
info = await this.androidExpoNativeModule.voice_connect(accessToken, params, customParameters);
|
|
28
|
-
} else if (Platform.OS === 'ios') {
|
|
29
|
-
info = await NativeModule.voice_connect_ios(accessToken, params, // @ts-ignore
|
|
30
|
-
customParameters);
|
|
31
|
-
} else {
|
|
32
|
-
throw new Error('Unsupported platform');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return new Call(info);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async disconnect() {
|
|
39
|
-
var _NativeModule$voice_d;
|
|
40
|
-
|
|
41
|
-
if (Platform.OS === 'android' && this.androidExpoNativeModule) {
|
|
42
|
-
var _this$androidExpoNati, _this$androidExpoNati2;
|
|
43
|
-
|
|
44
|
-
return (_this$androidExpoNati = (_this$androidExpoNati2 = this.androidExpoNativeModule).voice_disconnect) === null || _this$androidExpoNati === void 0 ? void 0 : _this$androidExpoNati.call(_this$androidExpoNati2);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return (_NativeModule$voice_d = NativeModule.voice_disconnect_ios) === null || _NativeModule$voice_d === void 0 ? void 0 : _NativeModule$voice_d.call(NativeModule);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
isExpoEnvironment() {
|
|
51
|
-
return Platform.OS === 'android';
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export const ExpoModule = new ExpoNativeModule();
|
|
57
|
-
export default ExpoModule;
|
|
58
|
-
//# sourceMappingURL=ExpoModule.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["ExpoModule.ts"],"names":["NativeModule","Platform","requireNativeModule","Call","ExpoNativeModule","OS","e","console","warn","voice_connect","accessToken","options","params","customParameters","info","androidExpoNativeModule","voice_connect_ios","Error","disconnect","voice_disconnect","voice_disconnect_ios","isExpoEnvironment","ExpoModule"],"mappings":";;AAAA,SAASA,YAAT,EAAuBC,QAAvB,QAAuC,UAAvC;AACA,SAASC,mBAAT,QAAoC,mBAApC;AACA,SAASC,IAAT,QAAqB,QAArB;;AAQA,MAAMC,gBAAN,CAAuB;AAAA;AAAA,qDAEnBH,QAAQ,CAACI,EAAT,KAAgB,SAAhB,GACI,CAAC,MAAM;AACL,UAAI;AACF,eAAOH,mBAAmB,CAAC,iBAAD,CAA1B;AACD,OAFD,CAEE,OAAOI,CAAP,EAAU;AACVC,QAAAA,OAAO,CAACC,IAAR,CAAa,yCAAb;AACA,eAAO,IAAP;AACD;AACF,KAPD,GADJ,GASI,IAXe;AAAA;;AAaF,QAAbC,aAAa,CAACC,WAAD,EAAsBC,OAAuB,GAAG,EAAhD,EAAoD;AACrE,UAAM;AAAEC,MAAAA,MAAM,GAAG,EAAX;AAAeC,MAAAA,gBAAgB,GAAG;AAAlC,QAAyCF,OAA/C;AACA,QAAIG,IAAJ;;AACA,QAAIb,QAAQ,CAACI,EAAT,KAAgB,SAAhB,IAA6B,KAAKU,uBAAtC,EAA+D;AAC7DD,MAAAA,IAAI,GAAG,MAAM,KAAKC,uBAAL,CAA6BN,aAA7B,CACXC,WADW,EAEXE,MAFW,EAGXC,gBAHW,CAAb;AAKD,KAND,MAMO,IAAIZ,QAAQ,CAACI,EAAT,KAAgB,KAApB,EAA2B;AAChCS,MAAAA,IAAI,GAAG,MAAMd,YAAY,CAACgB,iBAAb,CACXN,WADW,EAEXE,MAFW,EAGX;AACAC,MAAAA,gBAJW,CAAb;AAMD,KAPM,MAOA;AACL,YAAM,IAAII,KAAJ,CAAU,sBAAV,CAAN;AACD;;AACD,WAAO,IAAId,IAAJ,CAASW,IAAT,CAAP;AACD;;AAEe,QAAVI,UAAU,GAAG;AAAA;;AACjB,QAAIjB,QAAQ,CAACI,EAAT,KAAgB,SAAhB,IAA6B,KAAKU,uBAAtC,EAA+D;AAAA;;AAC7D,sCAAO,+BAAKA,uBAAL,EAA6BI,gBAApC,0DAAO,kDAAP;AACD;;AACD,oCAAOnB,YAAY,CAACoB,oBAApB,0DAAO,2BAAApB,YAAY,CAAnB;AACD;;AAEDqB,EAAAA,iBAAiB,GAAY;AAC3B,WAAOpB,QAAQ,CAACI,EAAT,KAAgB,SAAvB;AACD;;AA5CoB;;AA+CvB,OAAO,MAAMiB,UAAU,GAAG,IAAIlB,gBAAJ,EAAnB;AACP,eAAekB,UAAf","sourcesContent":["import { NativeModule, Platform } from './common';\nimport { requireNativeModule } from 'expo-modules-core';\nimport { Call } from './Call';\nimport type { NativeCallInfo } from './type/Call';\n\ninterface ConnectOptions {\n params?: Record<string, any>;\n customParameters?: Record<string, any>;\n}\n\nclass ExpoNativeModule {\n private androidExpoNativeModule =\n Platform.OS === 'android'\n ? (() => {\n try {\n return requireNativeModule('TwilioVoiceExpo');\n } catch (e) {\n console.warn('TwilioVoiceExpo native module not found');\n return null;\n }\n })()\n : null;\n\n async voice_connect(accessToken: string, options: ConnectOptions = {}) {\n const { params = {}, customParameters = {} } = options;\n let info: NativeCallInfo;\n if (Platform.OS === 'android' && this.androidExpoNativeModule) {\n info = await this.androidExpoNativeModule.voice_connect(\n accessToken,\n params,\n customParameters\n );\n } else if (Platform.OS === 'ios') {\n info = await NativeModule.voice_connect_ios(\n accessToken,\n params,\n // @ts-ignore\n customParameters\n );\n } else {\n throw new Error('Unsupported platform');\n }\n return new Call(info);\n }\n\n async disconnect() {\n if (Platform.OS === 'android' && this.androidExpoNativeModule) {\n return this.androidExpoNativeModule.voice_disconnect?.();\n }\n return NativeModule.voice_disconnect_ios?.();\n }\n\n isExpoEnvironment(): boolean {\n return Platform.OS === 'android';\n }\n}\n\nexport const ExpoModule = new ExpoNativeModule();\nexport default ExpoModule;\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Call } from './Call';
|
|
2
|
-
interface ConnectOptions {
|
|
3
|
-
params?: Record<string, any>;
|
|
4
|
-
customParameters?: Record<string, any>;
|
|
5
|
-
}
|
|
6
|
-
declare class ExpoNativeModule {
|
|
7
|
-
private androidExpoNativeModule;
|
|
8
|
-
voice_connect(accessToken: string, options?: ConnectOptions): Promise<Call>;
|
|
9
|
-
disconnect(): Promise<any>;
|
|
10
|
-
isExpoEnvironment(): boolean;
|
|
11
|
-
}
|
|
12
|
-
export declare const ExpoModule: ExpoNativeModule;
|
|
13
|
-
export default ExpoModule;
|
package/src/ExpoModule.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { NativeModule, Platform } from './common';
|
|
2
|
-
import { requireNativeModule } from 'expo-modules-core';
|
|
3
|
-
import { Call } from './Call';
|
|
4
|
-
import type { NativeCallInfo } from './type/Call';
|
|
5
|
-
|
|
6
|
-
interface ConnectOptions {
|
|
7
|
-
params?: Record<string, any>;
|
|
8
|
-
customParameters?: Record<string, any>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
class ExpoNativeModule {
|
|
12
|
-
private androidExpoNativeModule =
|
|
13
|
-
Platform.OS === 'android'
|
|
14
|
-
? (() => {
|
|
15
|
-
try {
|
|
16
|
-
return requireNativeModule('TwilioVoiceExpo');
|
|
17
|
-
} catch (e) {
|
|
18
|
-
console.warn('TwilioVoiceExpo native module not found');
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
})()
|
|
22
|
-
: null;
|
|
23
|
-
|
|
24
|
-
async voice_connect(accessToken: string, options: ConnectOptions = {}) {
|
|
25
|
-
const { params = {}, customParameters = {} } = options;
|
|
26
|
-
let info: NativeCallInfo;
|
|
27
|
-
if (Platform.OS === 'android' && this.androidExpoNativeModule) {
|
|
28
|
-
info = await this.androidExpoNativeModule.voice_connect(
|
|
29
|
-
accessToken,
|
|
30
|
-
params,
|
|
31
|
-
customParameters
|
|
32
|
-
);
|
|
33
|
-
} else if (Platform.OS === 'ios') {
|
|
34
|
-
info = await NativeModule.voice_connect_ios(
|
|
35
|
-
accessToken,
|
|
36
|
-
params,
|
|
37
|
-
// @ts-ignore
|
|
38
|
-
customParameters
|
|
39
|
-
);
|
|
40
|
-
} else {
|
|
41
|
-
throw new Error('Unsupported platform');
|
|
42
|
-
}
|
|
43
|
-
return new Call(info);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async disconnect() {
|
|
47
|
-
if (Platform.OS === 'android' && this.androidExpoNativeModule) {
|
|
48
|
-
return this.androidExpoNativeModule.voice_disconnect?.();
|
|
49
|
-
}
|
|
50
|
-
return NativeModule.voice_disconnect_ios?.();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
isExpoEnvironment(): boolean {
|
|
54
|
-
return Platform.OS === 'android';
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const ExpoModule = new ExpoNativeModule();
|
|
59
|
-
export default ExpoModule;
|