voice-react-native-sdk 1.6.2-fork.4 → 1.6.2-fork.40
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 +17 -9
- 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
|
}
|
|
@@ -103,36 +103,41 @@ public class VoiceService extends Service {
|
|
|
103
103
|
// apparently the system can recreate the service without sending it an intent so protect
|
|
104
104
|
// against that case (GH-430).
|
|
105
105
|
if (null != intent) {
|
|
106
|
+
final CallRecordDatabase.CallRecord callRecord = getCallRecordDatabase().get(new CallRecordDatabase.CallRecord(Objects.requireNonNull(getMessageUUID(intent))));
|
|
107
|
+
if (null == callRecord) {
|
|
108
|
+
logger.warning("No call record found");
|
|
109
|
+
return START_NOT_STICKY;
|
|
110
|
+
}
|
|
106
111
|
switch (Objects.requireNonNull(intent.getAction())) {
|
|
107
112
|
case ACTION_INCOMING_CALL:
|
|
108
|
-
incomingCall(
|
|
113
|
+
incomingCall(callRecord);
|
|
109
114
|
break;
|
|
110
115
|
case ACTION_ACCEPT_CALL:
|
|
111
116
|
try {
|
|
112
|
-
acceptCall(
|
|
117
|
+
acceptCall(callRecord);
|
|
113
118
|
} catch (SecurityException e) {
|
|
114
119
|
sendPermissionsError();
|
|
115
120
|
logger.warning(e, "Cannot accept call, lacking necessary permissions");
|
|
116
121
|
}
|
|
117
122
|
break;
|
|
118
123
|
case ACTION_REJECT_CALL:
|
|
119
|
-
rejectCall(
|
|
124
|
+
rejectCall(callRecord);
|
|
120
125
|
break;
|
|
121
126
|
case ACTION_CANCEL_CALL:
|
|
122
|
-
cancelCall(
|
|
127
|
+
cancelCall(callRecord);
|
|
123
128
|
break;
|
|
124
129
|
case ACTION_CALL_DISCONNECT:
|
|
125
|
-
disconnect(
|
|
130
|
+
disconnect(callRecord);
|
|
126
131
|
break;
|
|
127
132
|
case ACTION_RAISE_OUTGOING_CALL_NOTIFICATION:
|
|
128
|
-
raiseOutgoingCallNotification(
|
|
133
|
+
raiseOutgoingCallNotification(callRecord);
|
|
129
134
|
break;
|
|
130
135
|
case ACTION_CANCEL_ACTIVE_CALL_NOTIFICATION:
|
|
131
|
-
cancelActiveCallNotification(
|
|
136
|
+
cancelActiveCallNotification(callRecord);
|
|
132
137
|
break;
|
|
133
138
|
case ACTION_FOREGROUND_AND_DEPRIORITIZE_INCOMING_CALL_NOTIFICATION:
|
|
134
139
|
foregroundAndDeprioritizeIncomingCallNotification(
|
|
135
|
-
|
|
140
|
+
callRecord);
|
|
136
141
|
break;
|
|
137
142
|
case ACTION_PUSH_APP_TO_FOREGROUND:
|
|
138
143
|
logger.warning("VoiceService received foreground request, ignoring");
|
|
@@ -329,7 +334,8 @@ public class VoiceService extends Service {
|
|
|
329
334
|
createOrReplaceNotification(callRecord.getNotificationId(), notification);
|
|
330
335
|
|
|
331
336
|
// stop active sound (if any)
|
|
332
|
-
|
|
337
|
+
// 11-14-25: We can keep the sound playing to indicate that the call is still pending pickup.
|
|
338
|
+
//VoiceApplicationProxy.getMediaPlayerManager().stop();
|
|
333
339
|
|
|
334
340
|
// notify JS layer
|
|
335
341
|
sendJSEvent(
|
|
@@ -386,9 +392,11 @@ public class VoiceService extends Service {
|
|
|
386
392
|
private static UUID getMessageUUID(@NonNull final Intent intent) {
|
|
387
393
|
return (UUID)intent.getSerializableExtra(Constants.MSG_KEY_UUID);
|
|
388
394
|
}
|
|
395
|
+
/*
|
|
389
396
|
private static CallRecordDatabase.CallRecord getCallRecord(final UUID uuid) {
|
|
390
397
|
return Objects.requireNonNull(getCallRecordDatabase().get(new CallRecordDatabase.CallRecord(uuid)));
|
|
391
398
|
}
|
|
399
|
+
*/
|
|
392
400
|
private static void sendJSEvent(@NonNull String scope, @NonNull WritableMap event) {
|
|
393
401
|
getJSEventEmitter().sendEvent(scope, event);
|
|
394
402
|
}
|
|
@@ -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;
|