Utility Methods API for Dart SDK

The methods on this page are utility methods that don't fit into other categories.

Pause​

Call the pause() method to force the SDK to stop all requests to PubNub server when there are active subscribe channels.

Method(s)​

To pause() the data transmission you can use the following method(s) in Dart SDK.

1pause()

This method doesn't take any arguments.

Sample code​

Reference code
This example is a self-contained code snippet ready to be run. It includes necessary imports and executes methods with console logging. Use it as a reference when working with other examples in this document.
1import 'package:pubnub/pubnub.dart';
2
3void main() async {
4 // Create PubNub instance with default keyset.
5 var pubnub = PubNub(
6 defaultKeyset: Keyset(
7 subscribeKey: 'demo',
8 publishKey: 'demo',
9 userId: UserId('myUniqueUserId'),
10 ),
11 );
12
13 // Subscribe to a channel
14 var channel = "getting_started";
15 var subscription = pubnub.subscribe(channels: {channel});
show all 24 lines

Resume​

Call the resume() method to force the SDK to try and reach out PubNub.

Method(s)​

To resume() the data transmission you can use the following method(s) in Dart SDK.

resume()

Sample code​

1subscription.resume()

This method doesn't take any arguments.

Time​

This function returns the current timetoken value from the PubNub network.

Algorithm constructing the timetoken
1timetoken = (Unix epoch time in seconds) * 10000000

Example of creating a timetoken for a specific time and date:

108/19/2013 @ 9:20pm in UTC = 1376961606
2timetoken = 1376961606 * 10000000
3timetoken = 13769616060000000

Method(s)​

To fetch Time you can use the following method(s) in Dart SDK:

1time()

Sample code​

1var response = await pubnub.time();

Returns​

The time() operation returns a Timetoken which contains the following operations:

MethodDescription
value
Type: int
Returns an int representation of current timetoken.

Was this page useful?

Last updated on