Skip to content

Commit a4e7395

Browse files
committed
fix: add missing awaits to register/unregister functions
1 parent 9b6e5c8 commit a4e7395

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
* Feat: [Web] Add Twilio Device `updateToken(String)` function to allow updating of active device tokens.
55
* Fix: [Web] Twilio Device does not unregister on `unregister()` method call due to 'device.off' not visible in js object causing device event listeners to remain attached on unregistered device.
66
* Feat: [Web] Check unnecessary updating device with the same token.
7-
* Feat: [Web] Update internal [CallStatus] mapping method.
7+
* Feat: [Web] Update internal [CallStatus] mapping method.
8+
* Fix: [Web] Await Twilio Device `register()` and `unregister()` method calls.
89
* Feat: update example.
910
* Docs: update CHANGELOG
1011

lib/_internal/twilio_voice_web.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ class TwilioVoiceWeb extends MethodChannelTwilioVoice {
319319
return true;
320320
}
321321
try {
322-
device?.unregister();
322+
final promise = device!.unregister();
323+
await js_util.promiseToFuture(promise);
323324
_detachDeviceListeners(device!);
324325
_clearCalls();
325326
return true;
@@ -382,10 +383,11 @@ class TwilioVoiceWeb extends MethodChannelTwilioVoice {
382383
/// create new Twilio device
383384
device = twilio_js.Device(accessToken, options);
384385
_call.device = device;
385-
_attachDeviceListeners(device!);
386+
_attachDeviceListeners(device!);
386387

387-
// Register device to accept notifications
388-
device!.register();
388+
// Register device to accept notifications
389+
final promise = device!.register();
390+
await js_util.promiseToFuture(promise);
389391
}
390392

391393
return true;

0 commit comments

Comments
 (0)