getUnreadStream method

  1. @override
Stream getUnreadStream()
override

You can check how many unread conversations a user has even if a user dismisses a notification.

You can listen for unread conversation count with this method.

Implementation

@override
Stream<dynamic> getUnreadStream() {
  // It's fine to let the StreamController be garbage collected once all the
  // subscribers have cancelled; this analyzer warning is safe to ignore.
  // ignore: close_sinks
  StreamController<dynamic> _unreadController =
      StreamController<dynamic>.broadcast();
  _unreadController.onListen = () {
    js.context.callMethod('Intercom', [
      'onUnreadCountChange',
      js.allowInterop((unreadCount) {
        _unreadController.add(unreadCount);
      }),
    ]);
  };
  return _unreadController.stream;
}