pubnub 4.3.4 copy "pubnub: ^4.3.4" to clipboard
pubnub: ^4.3.4 copied to clipboard

PubNub SDK v5 for Dart lang (with Flutter support) that allows you to create real-time applications

example/example.dart

import 'package:pubnub/pubnub.dart';

void main() async {
  // Create PubNub instance with default keyset.
  var pubnub = PubNub(
      defaultKeyset:
          Keyset(subscribeKey: 'demo', publishKey: 'demo', uuid: UUID('demo')));

  // Subscribe to a channel
  var subscription = pubnub.subscribe(channels: {'test'});

  subscription.messages.take(1).listen((envelope) async {
    print(envelope.payload);

    await subscription.dispose();
  });

  await Future.delayed(Duration(seconds: 3));

  // Publish a message
  await pubnub.publish('test', {'message': 'My message!'});

  // Channel abstraction for easier usage
  var channel = pubnub.channel('test');

  await channel.publish({'message': 'Another message'});

  // Work with channel History API
  var history = channel.messages();
  var count = await history.count();

  print('Messages on test channel: $count');
}
48
likes
110
pub points
91%
popularity

Publisher

verified publisherpubnub.com

PubNub SDK v5 for Dart lang (with Flutter support) that allows you to create real-time applications

Homepage

Documentation

API reference

License

unknown (LICENSE)

Dependencies

async, cbor, convert, crypto, encrypt, form_data, meta, pedantic, pool, xml

More

Packages that depend on pubnub