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

outdated

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 = await pubnub.subscribe(channels: {'test'});

  subscription.messages.take(1).listen((message) {
    print(message);
  });

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

  // Unsubscribe
  await subscription.unsubscribe();

  // 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');
}
50
likes
0
pub points
92%
popularity

Publisher

verified publisherpubnub.com

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

Homepage

License

unknown (license)

Dependencies

cbor, crypto, dio, meta, pool

More

Packages that depend on pubnub