Giter Site home page Giter Site logo

dart's Introduction

PubNub Dart SDK

This is the official PubNub Dart SDK repository.

PubNub takes care of the infrastructure and APIs needed for the realtime communication layer of your application. Work on your app's logic and let PubNub handle sending and receiving data across the world in less than 100ms.

This repository contains the following packages:

  • pubnub Pub Version - a Flutter-friendly SDK written in Dart that allows you to connect to PubNub Data Streaming Network and add real-time features to your application.

  • pubnub_flutter - a collection of widgets for PubNub Dart SDK that allows you to create PubNub powered cross-platform applications with ease.

Get keys

You will need the publish and subscribe keys to authenticate your app. Get your keys from the Admin Portal.

Configure PubNub

  1. Integrate the Dart SDK into your project using the pub package manager by adding the following dependency in your pubspec.yml file:

    dependencies:
      pubnub: ^4.2.2

    Make sure to provide the latest version of the pubnub package in the dependency declaration.

  2. From the directory where your pubspec.yml file is located, run the dart pub get or flutter pub get command to install the PubNub package.

  3. Configure your keys:

    var pubnub = PubNub(
      defaultKeyset:
          Keyset(subscribeKey: 'mySubscribeKey', publishKey: 'myPublishKey', uuid: UUID('ReplaceWithYourClientIdentifier')));

Add event listeners

/*A Subscription contains a Dart Stream of messages from the channel(s) to which you are subscribed. You can transform that stream in the usual ways, or add a listener using listen:*/
  subscription.messages.listen((envelope) {
    switch (envelope.messageType) {
      case MessageType.normal:
          print('${envelope.publishedBy} sent a message: ${envelope.content}');
          break;
      case MessageType.signal:
          print('${envelope.publishedBy} sent a signal message: ${envelope.content}');
        break;
      case MessageType.objects:
          print('object event received from ${envelope.publishedBy} with data ${envelope.payload['data']}');
        break;
      case MessageType.messageAction:
          print('message action event ${envelope.payload['event']} received with data ${envelope.payload['data']}');
        break;
      case MessageType.file:
          var fileInfo = envelope.payload['file'];
          var id = fileInfo['id']; // unique file id
          var name = fileInfo['name']; // file name
          print('${envelope.publishedBy} sends file $name with message  ${envelope.payload['message']}');
        break;
      default:
        print('${envelope.publishedBy} sent a message: ${envelope.content}');
    }
  });

  subscription.presence.listen((event) {
      print('''Presence Event with action: ${event.action},
      received from uuid: ${event.uuid}
      with time token: ${event.timetoken},
      Total Occupancy now is: ${event.occupancy}
      ''');
  });

var envelope =
    await subscription.messages.firstWhere((envelope) => envelope.channel == 'my_channel');

Publish/subscribe

var channel = "getting_started";
var subscription = pubnub.subscribe(channels: {channel});

await pubnub.publish(channel, "Hello world");

Documentation

Support

If you need help or have a general question, contact [email protected].

dart's People

Contributors

are avatar are-pubnub avatar client-engineering-bot avatar crimsonred avatar madisonsmith avatar mohitpubnub avatar parfeon avatar seba-aln avatar techwritermat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dart's Issues

messageAction coming without UUID - required to implement group receipts

While adding messageAction we are adding UUID

below is the code for adding messageAction:

var result = await client.addMessageAction(
ourEntity.entity["type"],
ourEntity.entity["value"],
ourEntity.channel,
Timetoken(ourEntity.timeTokenValue));
print("uuid" + result.data.uuid);

below is the output based on this code, on messageAction sender side:

result = {AddMessageActionResult}
_status = 200
_data = {MessageAction}
type = "receipt"
value = "delivered"
actionTimetoken = "15990275006608580"
messageTimetoken = "15990274867947560"
uuid = "abcuser"
_error = null

but while receiving the messageAction UUID is missing, without this we cannot figure out which user has sent the receipt in a multi user group:

{source: actions, version: 1.0, data: {messageTimetoken: 15990253633518319, type: receipt, value: delivered, actionTimetoken: 15990253638833420}, event: added}

Also while testing and writing samples, multiuser channels should be kept in mind as base criteria, because expecting people will only use it for 1on1 communication is the opposite of a massively scalable tag line.

Pubnub.subscribe get error exception

I try pubnub.subscribe method and it gets an error exception on subscibribe_loop.dart from the library.

Screenshot 2020-12-19 at 22 35 10

This is my code.

_pubnub = PubNub(defaultKeyset:keyset)

`Subscription subscribeChannels({
Set channels,
Set channelGroups,
}) {

Subscription result = this._pubnub.subscribe(
      channels: channels,
      channelGroups: channelGroups,
    );

return result;

}`

pubnub: ^3.2.0 version solving failed.

Because of Pubnub version (3.2.0), I am facing an error while upgrading other dependencies in my project. It seems that this error is because pubnub 3.2.0 depends on crypto ^2.1.5 and other dependencies supports crypto ^3.0.1. So pubnub should support the latest one too.

flutter pub get

Because pubnub 3.2.0 depends on crypto ^2.1.5 and no versions of pubnub match >3.2.0 <4.0.0, pubnub ^3.2.0 requires crypto ^2.1.5.
So, because signageplayer depends on both pubnub ^3.2.0 and crypto ^3.0.1, version solving failed.
pub get failed (1; So, because demoproject depends on both pubnub ^3.2.0 and crypto ^3.0.1, version solving failed.)

List of Few Dependencies Facing an issue :

  • universal_html: ^2.0.8
  • wakelock: ^0.5.0+2
  • archive: ^3.1.2

Look into this issue quickly and do the needful.

Thanks

Where to set presenceTimeout in Pubnub configuration ?

I have few issues of NULL_SAFETY so I am using 4.0.0-beta.1 version in my code. I am not able to configure PresenceTimeout value into it. So I am not able to know from server that weather my connection is alive or not..

Please let me know if any else is implemented from your side.

Thanks

Unable to send images using the sendFile()

pubnub.files.sendFile(this.currentChannel, filename, _image.readAsBytesSync()).then((value){
print(value);
});

I am sending the image file in the above way but i am getting the following error

Unhandled Exception: PubNubException: Request to third party service failed. Details: Query String Parameters not allowed on POST requests.

ConcurrentModificationError during pubnub.unsubscribeAll()

Good day,
I catch next unhandled error:
изображение
There is only one unsubscribeAll call in the whole code, and I checked that there is only one call of this part of code in the same time.

Call stack:
изображение

Variables:
изображение

pubnub: ^3.2.0

flutter doctor -v
изображение

Presence - Heartbeat Interval Should Be Heartbeat / 2 - 1

According to the PubNub REST API | Long running heartbeat calls, the heartbeatInterval should "automatically" be set to heartbeat / 2 -1:

if the client is set for a HB of x, the HBI is automatically set to x / 2 - 1. This enables, by default, that under excellent to average-bad network scenarios, the client should be able to "ping" the Presence server between 1 and 2 times before its HB timeout limit.

I believe that this is currently not reflected in the dart SDK.

Subscribe

Currently, the heartbeatInterval can be set via the SubscribeKeysetExtension:

set heartbeatInterval(int value) => settings['#heartbeatInterval'] = value;

This heartbeatInterval is then directly used as heartbeat value when subscribing to a channel in SubscribeParams:

'heartbeat': keyset.heartbeatInterval.toString()

Shouldn't the heartbeat that is sent in this request be (heartbeatInterval + 1) * 2?

PresenceWidget

In the PresenceWidget, the same heartbeatInterval is used both for setting the periodic Timer

   timer = Timer.periodic(
        Duration(seconds: widget.heartbeatInterval), _sendHeartbeat);

and as hearbeat sent to the server

  Future<void> _sendHeartbeat(Timer timer) async {
    ...
    await _pubnub.announceHeartbeat(
      heartbeat: widget.heartbeatInterval, // <== here
      channels: channels,
      channelGroups: channelGroups,
      keyset: widget.keyset,
      using: widget.using,
    );
  }

Shouldn't also there the heartbeat rather be (heartbeatInterval + 1) * 2?

Because with the current implementation, we got a lot of timeout presence events when the internet connection was not perfect.

Suggestion

I would strongly suggest to introduce an additional presenceTimeout and automatically set it to (heartbeatInterval + 1) * 2. Or the other way around and set the heartbeatInterval based on presenceTimeout, as e.g. done in the JavaScript SDK:

https://github.com/pubnub/javascript/blob/499b14bf6e0802c6389e6038add9bfd37af45601/src/core/components/config.js#L263

  setPresenceTimeout(val: number): this {
    ...
    this.setHeartbeatInterval(this._presenceTimeout / 2 - 1);
    return this;
  }

https://github.com/pubnub/javascript/blob/403e14cac7da6820239749686251080be4760022/src/core/endpoints/subscribe.js#L56

  const params: Object = {
    heartbeat: config.getPresenceTimeout(),
  };

DioError : HttpException: Connection closed before full header was received

Running in an emulator, my Flutter app occasionally there will be an exception thrown:

Exception has occurred.
DioError (DioError [DioErrorType.DEFAULT]: HttpException: Connection closed before full header was received, uri = https://ps.pndsn.com/v2/subscribe/sub-c-81c1977e-15ff-11e5-b66b-02ee2ddab7fe/familyUser-22/0?tt=15914051777763439&tr=2&pnsdk=PubNub-Dart%2F1.1.3)

I understand that Dio is a dependency of this package. Do you have a working Flutter app example with code on Github that I can take a look at to see how to get past this DioError?

Flutter Doctor:

[✓] Flutter (Channel stable, v1.17.1, on Mac OS X 10.14.6 18G3020, locale en-US)
    • Flutter version 1.17.1 at /Users/trumanleung/flutter
    • Framework revision f7a6a7906b (3 weeks ago), 2020-05-12 18:39:00 -0700
    • Engine revision 6bc433c6b6
    • Dart version 2.8.2

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/trumanleung/Library/Android/sdk
    • Platform android-29, build-tools 29.0.2
    • ANDROID_HOME = /Users/trumanleung/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C504
    ! CocoaPods 1.7.5 out of date (1.8.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the
        Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade:
        sudo gem install cocoapods

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 42.0.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.45.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.10.2

[✓] Connected device (1 available)
    • iPhone 7 Plus • DE6389DF-156A-4D40-AD6C-02ED0BA182BD • ios • com.apple.CoreSimulator.SimRuntime.iOS-11-4 (simulator)

Method missing or not added in 3.0.0

hey @are :

one question

is this added ?


 pubnub.supervisor.events.listen((event) {
      // Check NetworkIsDownEvent OR NetworkIsUpEvent
    });

and is this not added as in your comments you told me to use ?

pubnub.signals.networkIsConnected.listen((isUp) {
  if (isUp) {
    print('network reconnected');
  } else {
    print('network disconnected');
  }
});

Please refer this :
#19

Upgrading to v2.0.0 failing

When trying to upgrade SDK version to 2.0.0 giving following error:

Because pubnub >=1.4.4 depends on xml ^4.3.0 which depends on meta ^1.2.0, pubnub >=1.4.4 requires meta ^1.2.0.
And because every version of flutter from sdk depends on meta 1.1.8, pubnub >=1.4.4 is incompatible with flutter from sdk.
So, because appname_pubnub depends on both flutter any from sdk and pubnub ^2.0.0, version solving failed.
pub get failed (1; So, because appname_pubnub depends on both flutter any from sdk and pubnub ^2.0.0, version solving failed.)

Our Flutter version:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.20.2, on Microsoft Windows [Version 10.0.18363.1016], locale en-IN)

We checked the pubsec.yaml file of SDK and the version of package "meta" is 1.1.0 and it seems minimum required is 1.1.8 or 1.2.0 due to which upgrade is failing.

pubnub error "Signature does not match"

when i try code:

 PubNub pubNub = PubNub(
                  defaultKeyset: Keyset(
                    publishKey: 'myPublishKey',
                    subscribeKey: 'mySubscribeKey',
                    secretKey: 'mySecretKey',
                  ),
                );
final createUser = await pubNub.objects.setUUIDMetadata(
                    UuidMetadataInput(
                      name: 'userName',
                      email: '[email protected]',
                    ),
                    uuid: 'uuild');

error:

Exception has occurred. PubNubException (PubNubException: 403 error: Signature does not match #0 new PubNubException (package:pubnub/src/core/exceptions.dart:9:29) #1 getExceptionFromDefaultResult (package:pubnub/src/dx/_utils/exceptions.dart:41:10) #2 getExceptionFromAny (package:pubnub/src/dx/_utils/exceptions.dart:7:12) #3 _defaultFlow (package:pubnub/src/dx/_utils/default_flow.dart:82:11) <asynchronous suspension> #4 Fiber.run (package:pubnub/src/core/supervisor/fiber.dart:37:20) <asynchronous suspension> #5 defaultFlow (package:pubnub/src/dx/_utils/default_flow.dart:27:3) <asynchronous suspension> #6 _MyHomePageState.build.<anonymous closure> (package:flutter_pubnub_chat/main.dart:116:36) <asynchronous suspension> )

Meta encoding problem

Building our chat app, I found interesting bug: spaces in usernames in messages sent from flutter client appear as plus signs. But when the same messages were loaded from history, usernames showed normally.

Screenshot

Here is the demo https://github.com/vikmind/pubnub_meta_demo (I used fork from #24 in the demo to load history with meta and to show the difference. The issue with messages from subscription does not depend on it)

Looks like the problem lies in the encoding differences when sending message to PubNub REST API, meta info goes into query part of the URI and dart client is encoding it according to spec.

I assume that transmitting server is interpreting it as URI component, where encoding is slightly different. My assumption is confirmed by the fact that JS SDK use encodeURIComponent for building query component. That's why such problem does not exist there.

So basically, dart sdk uses correct but different (from server and js sdk) encoding when sending additional parameters to REST API. And I am not sure where it should be patched 🤷

endsWith called on null

Subscribing to a single channel, with presence off, I get this error in the stream when I receive a message:

E/flutter (27261): [ERROR:flutter/shell/common/shell.cc(210)] Dart Unhandled Exception: NoSuchMethodError: The method 'endsWith' was called on null.
E/flutter (27261): Receiver: null
E/flutter (27261): Tried calling: endsWith("-pnpres"), stack trace: #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
E/flutter (27261): #1      Subscription.subscribe.<anonymous closure> (package:pubnub/src/dx/subscribe/subscription.dart:89:28)
E/flutter (27261): #2      Stream.asyncMap.<anonymous closure>.<anonymous closure> (dart:async/stream.dart:588:29)

The cause is this if statement:

        if ((envelope['e'] == null || envelope['e'] == 4) &&
            !envelope['b'].endsWith('-pnpres') &&
            _keyset.cipherKey != null) {

The second line doesn't handle envelope['b'] being null, which it is in my case:

{a: 3, f: 0, i: 6c79b67b-4893-43d4-89d7-3150ef9ff5d4, s: 27, o: {t: 16119953058400500}, p: {t: 16119953063972070, r: 4}, k: sub-<deleted>, c: driver-updates.222204464, d: {event: orders_changed}}

Fetch messages with message actions

Hi, I was searching in the documentation and I didn't find how to get history of a channel with actions like in JS:

pubnub.fetchMessages( { channels: ['ch-1'], start: "15343325214676133", includeMessageActions: true, count: 25 }, (status, response) => { // handle response } );

Thanks!

fetchMessage brining all messages instead of only missed messages

We have upgraded SDK to 2.0.1 by overriding meta package.

Now getting messages from History with timeToken, but facing an issue with fetching messages after an end time token upto newest messages. Scenario 2 as explained in this link
https://www.pubnub.com/docs/platform/messages/storage

Below is the code and logs for your reference, you can see the messages returned by history has a time token prior to end time token we have set whereas only messages only after the timeToken mentioned should be returned.

Code:

final messageHistory = await client.batch.fetchMessages(
list.toSet(),
end: Timetoken.fromDateTime(
DateTime.fromMillisecondsSinceEpoch(lastMessage.timeToken)),
reverse: true,
);

Debug Logs:

lastMessageTime => 15997452027059086

messageHistory => 1
history message {content: hi, time: 1599743961077, fromUser: br-test, pn_gcm: {data: {content: hi, channel: ch_br-test_rr-test, messageId: b093a258-0d25-4f03-92cd-a438af1a796a}, pn_exceptions: [eoIyYl38TQOMJ8gNmpJ37R:APA91bGvsgjmv7w7rwZroCAl2n-vLgW_erGVioAyDzHLwDumOo7LqQR9fiMfB8U3QBIW4dh7pgI0z_KegmJrFuWci8lvWszYgELkuuc1RFqO8qVgHVXDYwMHBiAxPzDGDe-_P4umcFQN]}, type: text, id: b093a258-0d25-4f03-92cd-a438af1a796a, channel: ch_br-test_rr-test} => time token 15997439631767736
incoming => 15997439631767736
history message {content: qwerty, time: 1599744036071, fromUser: br-test, pn_gcm: {data: {content: qwerty, channel: ch_br-test_rr-test, messageId: 92f5eef8-074c-4345-aa7e-c5708cbe6363}, pn_exceptions: [eoIyYl38TQOMJ8gNmpJ37R:APA91bGvsgjmv7w7rwZroCAl2n-vLgW_erGVioAyDzHLwDumOo7LqQR9fiMfB8U3QBIW4dh7pgI0z_KegmJrFuWci8lvWszYgELkuuc1RFqO8qVgHVXDYwMHBiAxPzDGDe-_P4umcFQN]}, type: text, id: 92f5eef8-074c-4345-aa7e-c5708cbe6363, channel: ch_br-test_rr-test} => time token 15997440367618732
incoming => 15997440367618732
history message {content: qa, time: 1599744162619, fromUser: br-test, pn_gcm: {data: {content: qa, channel: ch_br-test_rr-test, messageId: fcfc2afd-6602-4e74-8a60-aac6fa325418}, pn_exceptions: [eoIyYl38TQOMJ8gNmpJ37R:APA91bGvsgjmv7w7rwZroCAl2n-vLgW_erGVioAyDzHLwDumOo7LqQR9fiMfB8U3QBIW4dh7pgI0z_KegmJrFuWci8lvWszYgELkuuc1RFqO8qVgHVXDYwMHBiAxPzDGDe-_P4umcFQN]}, type: text, id: fcfc2afd-6602-4e74-8a60-aac6fa325418, channel: ch_br-test_rr-test} => time token 15997441633913204
incoming => 15997441633913204
history message {content: was, time: 1599744175923, fromUser: br-test, pn_gcm: {data: {content: was, channel: ch_br-test_rr-test, messageId: 1e0a32d6-47f9-42da-b831-27e636931c89}, pn_exceptions: [eoIyYl38TQOMJ8gNmpJ37R:APA91bGvsgjmv7w7rwZroCAl2n-vLgW_erGVioAyDzHLwDumOo7LqQR9fiMfB8U3QBIW4dh7pgI0z_KegmJrFuWci8lvWszYgELkuuc1RFqO8qVgHVXDYwMHBiAxPzDGDe-_P4umcFQN]}, type: text, id: 1e0a32d6-47f9-42da-b831-27e636931c89, channel: ch_br-test_rr-test} => time token 15997441766302065
incoming => 15997441766302065
history message {content: qa, time: 1599744277041, fromUser: br-test, pn_gcm: {data: {content: qa, channel: ch_br-test_rr-test, messageId: c8c7fd96-dd0c-4acc-a4aa-6d3b02a502d2}, pn_exceptions: [eoIyYl38TQOMJ8gNmpJ37R:APA91bGvsgjmv7w7rwZroCAl2n-vLgW_erGVioAyDzHLwDumOo7LqQR9fiMfB8U3QBIW4dh7pgI0z_KegmJrFuWci8lvWszYgELkuuc1RFqO8qVgHVXDYwMHBiAxPzDGDe-_P4umcFQN]}, type: text, id: c8c7fd96-dd0c-4acc-a4aa-6d3b02a502d2, channel: ch_br-test_rr-test} => time token 15997442778196674
incoming => 15997442778196674
history message {content: asd, time: 1599744280757, fromUser: br-test, pn_gcm: {data: {content: asd, channel: ch_br-test_rr-test, messageId: 61eef2e5-54e5-4fec-8d88-baaeae8746aa}, pn_exceptions: [eoIyYl38TQOMJ8gNmpJ37R:APA91bGvsgjmv7w7rwZroCAl2n-vLgW_erGVioAyDzHLwDumOo7LqQR9fiMfB8U3QBIW4dh7pgI0z_KegmJrFuWci8lvWszYgELkuuc1RFqO8qVgHVXDYwMHBiAxPzDGDe-_P4umcFQN]}, type: text, id: 61eef2e5-54e5-4fec-8d88-baaeae8746aa, channel: ch_br-test_rr-test} => time token 15997442814539074
incoming => 15997442814539074
history message {content: fghj, time: 1599744285076, fromUser: br-test, pn_gcm: {data: {content: fghj, channel: ch_br-test_rr-test, messageId: 448ee5f3-428c-498f-81c9-dde41d4ecc95}, pn_exceptions: [eoIyYl38TQOMJ8gNmpJ37R:APA91bGvsgjmv7w7rwZroCAl2n-vLgW_erGVioAyDzHLwDumOo7LqQR9fiMfB8U3QBIW4dh7pgI0z_KegmJrFuWci8lvWszYgELkuuc1RFqO8qVgHVXDYwMHBiAxPzDGDe-_P4umcFQN]}, type: text, id: 448ee5f3-428c-498f-81c9-dde41d4ecc95, channel: ch_br-test_rr-test} => time token 15997442858297131
incoming => 15997442858297131
history message {content: klz, time: 1599744287938, fromUser: br-test, pn_gcm: {data: {content: klz, channel: ch_br-test_rr-test, messageId: ef00a17a-b583-4802-bc88-a5f66eb3e4fb}, pn_exceptions: [eoIyYl38TQOMJ8gNmpJ37R:APA91bGvsgjmv7w7rwZroCAl2n-vLgW_erGVioAyDzHLwDumOo7LqQR9fiMfB8U3QBIW4dh7pgI0z_KegmJrFuWci8lvWszYgELkuuc1RFqO8qVgHVXDYwMHBiAxPzDGDe-_P4umcFQN]}, type: text, id: ef00a17a-b583-4802-bc88-a5f66eb3e4fb, channel: ch_br-test_rr-test} => time token 15997442886405212
incoming => 15997442886405212
history message {content: asdfgghhh, time: 1599744309893, fromUser: br-test, pn_gcm: {data: {content: asdfgghhh, channel: ch_br-test_rr-test, messageId: 04e344c9-6a1d-4065-83b2-974feb27edd8}, pn_exceptions: [eoIyYl38TQOMJ8gNmpJ37R:APA91bGvsgjmv7w7rwZroCAl2n-vLgW_erGVioAyDzHLwDumOo7LqQR9fiMfB8U3QBIW4dh7pgI0z_KegmJrFuWci8lvWszYgELkuuc1RFqO8qVgHVXDYwMHBiAxPzDGDe-_P4umcFQN]}, type: text, id: 04e344c9-6a1d-4065-83b2-974feb27edd8, channel: ch_br-test_rr-test} => time token 15997443105914899
incoming => 15997443105914899
history message {content: wweee, time: 1599744496485, fromUser: br-test, pn_gcm: {data: {content: wweee, channel: ch_br-test_rr-test, messageId: 1646b3bc-edab-4a49-b423-d1db0e4ddcf6}, pn_exceptions: [eoIyYl38TQOMJ8gNmpJ37R:APA91bGvsgjmv7w7rwZroCAl2n-vLgW_erGVioAyDzHLwDumOo7LqQR9fiMfB8U3QBIW4dh7pgI0z_KegmJrFuWci8lvWszYgELkuuc1RFqO8qVgHVXDYwMHBiAxPzDGDe-_P4umcFQN]}, type: text, id: 1646b3bc-edab-4a49-b423-d1db0e4ddcf6, channel: ch_br-test_rr-test} => time token 15997444971171894
incoming => 15997444971171894
history message {content: aaaaa, time: 1599744715087, fromUser: br-test, pn_gcm: {data: {content: aaaaa, channel: ch_br-test_rr-test, messageId: e853794e-59a6-44b6-a626-d4ee76edde8f}, pn_exceptions: [eoIyYl38TQOMJ8gNmpJ37R:APA91bGvsgjmv7w7rwZroCAl2n-vLgW_erGVioAyDzHLwDumOo7LqQR9fiMfB8U3QBIW4dh7pgI0z_KegmJrFuWci8lvWszYgELkuuc1RFqO8qVgHVXDYwMHBiAxPzDGDe-_P4umcFQN]}, type: text, id: e853794e-59a6-44b6-a626-d4ee76edde8f, channel: ch_br-test_rr-test} => time token 15997447157732952
incoming => 15997447157732952
history message {content: acx, time: 1599744724886, fromUser: br-test, pn_gcm: {data: {content: acx, channel: ch_br-test_rr-test, messageId: 0812af69-6ebf-4873-9393-d1b75bfeaa2b}, pn_exceptions: [eoIyYl38TQOMJ8gNmpJ37R:APA91bGvsgjmv7w7rwZroCAl2n-vLgW_erGVioAyDzHLwDumOo7LqQR9fiMfB8U3QBIW4dh7pgI0z_KegmJrFuWci8lvWszYgELkuuc1RFqO8qVgHVXDYwMHBiAxPzDGDe-_P4umcFQN]}, type: text, id: 0812af69-6ebf-4873-9393-d1b75bfeaa2b, channel: ch_br-test_rr-test} => time token 15997447256655564
incoming => 15997447256655564
history message {content: asdfgh, time: 1599745178027, fromUser: br-test, pn_gcm: {data: {content: asdfgh, channel: ch_br-test_rr-test, messageId: d18b9057-52ca-4ca4-b6ed-9c4a2cda791f}, pn_exceptions: [eoIyYl38TQOMJ8gNmpJ37R:APA91bGvsgjmv7w7rwZroCAl2n-vLgW_erGVioAyDzHLwDumOo7LqQR9fiMfB8U3QBIW4dh7pgI0z_KegmJrFuWci8lvWszYgELkuuc1RFqO8qVgHVXDYwMHBiAxPzDGDe-_P4umcFQN]}, type: text, id: d18b9057-52ca-4ca4-b6ed-9c4a2cda791f, channel: ch_br-test_rr-test} => time token 15997451787186398
incoming => 15997451787186398
history message {content: qwerty, time: 1599745202023, fromUser: br-test, pn_gcm: {data: {content: qwerty, channel: ch_br-test_rr-test, messageId: 8dedd5f2-1eb7-41c1-8ad2-02455189cd4a}, pn_exceptions: [eoIyYl38TQOMJ8gNmpJ37R:APA91bGvsgjmv7w7rwZroCAl2n-vLgW_erGVioAyDzHLwDumOo7LqQR9fiMfB8U3QBIW4dh7pgI0z_KegmJrFuWci8lvWszYgELkuuc1RFqO8qVgHVXDYwMHBiAxPzDGDe-_P4umcFQN]}, type: text, id: 8dedd5f2-1eb7-41c1-8ad2-02455189cd4a, channel: ch_br-test_rr-test} => time token 15997452027059086
incoming => 15997452027059086

User Events is not found in Dart PubNub Package

User events are triggered when user metadata is set or deleted. Other users can receive these events by subscribing to the user's channel or if they are members of the same channel. In flutter PubNub package presently does not have such event handler who can handle update event.

MessageAction event listener for updating delivery and read receipts

Our use-case involves all recipients in the channel to send a Delivery and Read receipt for each received message, to the message sender. Like we have in popular messengers like Whatsapp.

We have used message transaction type messageAction for the same and able to update message as delivered and read on the server, once this is done server needs to relay this message to message sender client where delivery and read receipt need to be updated in the sent message record.

As per documentation of PubNub Event Listeners - Use event listener message action events that are published to notify clients when Message Actions are added to or removed from messages. To receive these events, clients should be subscribed to the channel, and add a messageAction listener.

We tried to implement messageAction listener but this option does not exist in Dart SDK or we may be missing something. For us message delivery and read receipts features are critical and we would like to implement it using messageAction, please suggest how this can be achieved with Dart SDK.

How to listen to typings events(signals) ?

I see in the object i can send signal through pubnub instance like this:

pubnub.signal('channel', {'text': 'typing_on', 'user': 'Liran'});

How can I receive this signal in a channel ? I try to find and play with it and could not succeed

Thanks

Connection problem

I have tried several approaches - the connection to pubnub in some point (even if the app is active and there is internet connection)
is disconnected and really really unstable - i cant get 3 devices "chatting" for more then 2 min without some connection drop:
and the worst thing is i dont have any indication from the sdk that its happening so i cant do anything to restore it.
This is a really big problem if u design chat system and really unreliable solution for me
this is the log:

I/flutter (10579): [2021-03-03 17:27:03.522314] (info) root.pubnub.networking.request_handler: (50) Resource released...
I/flutter (10579): [2021-03-03 17:27:03.526140] (warning) root.pubnub.subscribe.subscribe_loop: An exception has occured while running a subscribe fiber (retry #1).
I/flutter (10579): [2021-03-03 17:27:03.529552] (warning) root.pubnub.subscribe.subscribe_loop: No diagnostics found.
E/flutter (10579): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PubNubException: request timed out
E/flutter (10579): #0 new PubNubException
package:pubnub/…/core/exceptions.dart:9
E/flutter (10579): #1 new PubNubRequestTimeoutException
package:pubnub/…/net/exceptions.dart:8
E/flutter (10579): #2 RequestHandler.response.
package:pubnub/…/request_handler/io.dart:101
E/flutter (10579): #3 _rootRun (dart:async/zone.dart:1182:47)
E/flutter (10579): #4 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (10579): #5 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter (10579): #6 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1037:23)
I/flutter (10579): [2021-03-03 17:22:03.255180] (info) root.pubnub.networking.request_handler: (50) Starting request to "https://ps.pndsn.com/v2/subscribe/sub-c-923609da-6eac-11eb-9994-e2667f94577d/,/0?pnsdk=PubNub-Dart%2F3.1.0&tt=16147848536165710&tr=12&channel-group=chats-TkbjkY9uagMShBb9XNE9Yr5ZFTe2&uuid=TkbjkY9uagMShBb9XNE9Yr5ZFTe2"...
E/flutter (10579): #7 _rootRun (dart:async/zone.dart:1190:13)
E/flutter (10579): #8 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (10579): #9 _CustomZone.bindCallback. (dart:async/zone.dart:1021:23)
E/flutter (10579): #10 Timer._createTimer. (dart:async-patch/timer_patch.dart:18:15)
E/flutter (10579): #11 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:397:19)
E/flutter (10579): #12 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:428:5)
E/flutter (10579): #13 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
2

Thank you very much but I am afraid dart sdk is still not mature enough

Detect Websocket is connected or disconnected

We have upgraded the SDK to v 2.0.1 and imported the networking module with retry policy while making the connection as explained in response to question in issue 19.

But if the app is open and long poll interval is over the Websocket disconnects which is correct also sometimes it disconnects if we switch between apps or when network comes back after brief disconnection.

Our question is, is there a way to detect if socket connection is connected, connecting or disconnected is there a way to check and trigger reconnection if socket is disconnected.

Currently what we do is dispose and subscribe whenever app comes in foreground, is restarted or internet state changes but for long poll disconnection we don't have a way to handle as well as we don't want to do the unnecessary reconnection if the connection is already alive.

pubnub.batch.countMessages() cant work with AccessManager

pubnub.batch.countMessages() don't pass auth in QueryParam in this request.
Result: 403 status code in response, if Access Manager is active.

It is not important which type of param i use, Map<String,Timetoken> of List<String>.
But if i make request manually by http service, it works normally.

Error when registering device for push notifications from channels.

I have added FCM server key on the dashboard, and I am trying to register my device for push notifications from channels like this:
await client.addPushChannels(fcmToken, PushGateway.fcm, channelSet);

However I am receiving this error:

E/flutter (13240): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PubNubException: null error: Invalid type argument
E/flutter (13240): #0 new PubNubException (package:pubnub/src/core/exceptions.dart:6:29)
E/flutter (13240): #1 getExceptionFromDefaultResult (package:pubnub/src/dx/_utils/exceptions.dart:31:10)
E/flutter (13240): #2 getExceptionFromAny (package:pubnub/src/dx/_utils/exceptions.dart:6:12)
E/flutter (13240): #3 defaultFlow (package:pubnub/src/dx/_utils/default_flow.dart:34:11)
E/flutter (13240):
E/flutter (13240): #4 PushNotificationDx.addPushChannels (package:pubnub/src/dx/push/push.dart:74:12)

I also tried calling it other way like:

await client.device(fcmToken).registerToChannels(channelSet, PushGateway.fcm);

But the error stays the same. Any ideas about what could it be?

No way to catch/handle exceptions when 'No resolutions found.'

pubnub version: pubnub: ^4.0.0-beta.0

While trying to implement access management (PAM), I repeatedly had an issue where I would receive an RequestFailureException. The thrown Exception occurs in subscribe_loop.dart here:

        if (resolutions == null) {
          _logger.silly('No resolutions found.');
          rethrow;
        }

In my case it was caused by trying to subscribe to a channel too quickly after my backend had applied the appropriate grants. Effectively, I was making the subscribe call before PubNub had applied the grants.

To Reproduce:

  1. Enable PAM and do not apply permissions for the client.
  2. Subscribe to a channel without a grant.
  3. Error is raised as an unhandled exception

Please provide guidance on whether I need to do something different or there is an actual bug. There are two specific items I'm trying to do:

Connection Failure Handling
Know when a connection failure occurs so I can contact my backend server again to re-apply grants. It's not clear how I should implement the client to know when to handle a situation like this.

I tried wrapping subscribe call in a try/catch like this while trying to figure out what was going on, and the catch block was never hit.

    try {
      messageSubscription =
          pn?.subscribe(channels: {chatUser.channelName}, withPresence: true);
      messageSubscription?.messages.listen((message) {
        print(
            "RECEIVE for ${chatUser.channelName}: '${message.content}' with timetoken: ${message.publishedAt}");
      });
    } catch (e) {
      print("Exception Occurred while subscribing!");
    }

Subscribing Too Soon After Grant Applied
When my Flutter client initiates chat, I first make a call to my backend server to generate an auth key, apply grants, and then return the key to the client where it then creates the PubNub object and subscribes. This subscribe call frequently fails.

This appears to be caused by some side of PubNub-side delay. If I put a break point on my backend code (C#) after it makes the grant call to PubNub and then allow to return API call to the Flutter client after a few moments, the Flutter client can successfully subscribe to the channel.

I'm not sure this will be an issue once deployed as the latency from an end user to our servers to PubNub and back might be long enough to prevent this from happening. However, because of inability to detect connection failure, I'm not sure how handle this situation other than putting in an explicit delay client-side before attempting the subscribe call.

Exception while adding device for push notification

Call that caused the exception -

await pubnub.addPushChannels(fcmToken, PushGateway.gcm, Set.of(['chName']), using: 'wellowise');
// Same exception for listPushChannels call
Exception -
E/flutter ( 3660): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PubNubException: Cannot decode string as JSON
E/flutter ( 3660): #0      new PubNubException (package:pubnub/src/core/exceptions.dart:6:29)
E/flutter ( 3660): #1      new ParserException (package:pubnub/src/core/parse.dart:4:39)
E/flutter ( 3660): #2      PubNubParserModule.decode (package:pubnub/src/parser/parser.dart:11:13)
E/flutter ( 3660): #3      defaultFlow (package:pubnub/src/dx/_utils/default_flow.dart:29:35)
E/flutter ( 3660): <asynchronous suspension>
E/flutter ( 3660): #4      PushNotificationDx.addPushChannels (package:pubnub/src/dx/push/push.dart:75:12)

Missing messages

I've written a simple client/server implementation to do ping/pong with synthesized request/response and occasionally see missing messages. I know this is not a lot to go on but I'm a bit new to Dart and its async implementation and didn't know if there were any quick gotchas that I was missing. (The code is proprietary so it'll take me a good amount of time to put together a minimal, replicating sample...)

This is a good test session:

==>: Instance of 'Ping' {message: This is a ping..., kind: ping} -> null with Closure: (BaseMessage) => Future<bool>
### PublishResult: Sent
<==: Me: 982bfad1-d6c5-4c70-932a-3880a4456ad8 Them: 2d026693-c153-4925-a83c-7f27f06580e2 Payload: {message: This is a ping..., kind: ping, requestId: a24cb63f-224c-454b-8fdf-784eee49705b}
###: Instance of 'Ping' {message: This is a ping..., kind: ping, requestId: a24cb63f-224c-454b-8fdf-784eee49705b}
<<< PING: HANDLING >>>
==>: Instance of 'Pong' {message: Ponging back..., responseId: a24cb63f-224c-454b-8fdf-784eee49705b, kind: pong} -> null with null
<==: Me: 2d026693-c153-4925-a83c-7f27f06580e2 Them: 2d026693-c153-4925-a83c-7f27f06580e2 Payload: {message: This is a ping..., kind: ping, requestId: a24cb63f-224c-454b-8fdf-784eee49705b}
--- Skipping.  Sent by us.

#PublishResult: Sent
<==: Me: 2d026693-c153-4925-a83c-7f27f06580e2 Them: 982bfad1-d6c5-4c70-932a-3880a4456ad8 Payload: {message: Ponging back..., responseId: a24cb63f-224c-454b-8fdf-784eee49705b, kind: pong}
###: Instance of 'Pong' {message: Ponging back..., responseId: a24cb63f-224c-454b-8fdf-784eee49705b, kind: pong}
--- Response received: {message: Ponging back..., responseId: a24cb63f-224c-454b-8fdf-784eee49705b, kind: pong}

Once every 5-10 test runs, I get:

==>: Instance of 'Ping' {message: This is a ping..., kind: ping} -> null with Closure: (BaseMessage) => Future<bool>
### PublishResult: Sent
<==: Me: 0aff061f-3112-4938-a4e2-ddb72c6229a8 Them: null Payload: {action: join, uuid: 3b729277-94bd-49af-a299-2da97c34f9f9, timestamp: 1614026331, occupancy: 5}
+++ MSG was null.
<==: Me: 3b729277-94bd-49af-a299-2da97c34f9f9 Them: null Payload: {action: join, uuid: 3b729277-94bd-49af-a299-2da97c34f9f9, timestamp: 1614026331, occupancy: 5}
+++ MSG was null.
<==: Me: 0aff061f-3112-4938-a4e2-ddb72c6229a8 Them: null Payload: {action: join, uuid: 0aff061f-3112-4938-a4e2-ddb72c6229a8, timestamp: 1614026332, occupancy: 6}
+++ MSG was null.

In this case, the test sent out a "Ping" message but only got presence type messages (which aren't decoded in the system (hence the "MSG was null")) back. Is there some way that the presence messages could be disrupting the PubNub library? I've run through the code to see if I have any missing/messed-up async. Any suggestions?

Ah, got debug logging going. This is the failing log:

00:02 +0: loading lib/src/pubnub/e2e_test.dart                                                                                                                                           
[2021-02-22 13:20:01.439262] (silly) root.pubnub.subscribe.subscribe_loop: State has been updated.
[2021-02-22 13:20:01.443663] (verbose) root.pubnub.subscription.subscription: Resuming subscription.
[2021-02-22 13:20:01.444134] (silly) root.pubnub.subscribe.subscribe_loop: State has been updated.
[2021-02-22 13:20:01.445616] (silly) root.pubnub.subscribe.subscribe_loop: Starting new loop iteration.
00:02 +0: E2E                                                                                                                                                                            
SUB:  false false
00:02 +0: loading lib/src/pubnub/e2e_test.dart                                                                                                                                           
[2021-02-22 13:20:01.448234] (silly) root.pubnub.subscribe.subscribe_loop: State has been updated.
[2021-02-22 13:20:01.448309] (verbose) root.pubnub.subscription.subscription: Resuming subscription.
[2021-02-22 13:20:01.448392] (silly) root.pubnub.subscribe.subscribe_loop: State has been updated.
[2021-02-22 13:20:01.450067] (silly) root.pubnub.subscribe.subscribe_loop: Starting new loop iteration.
00:02 +0: E2E                                                                                                                                                                            
SUB:  false false
==>: Instance of 'Ping' {message: This is a ping..., kind: ping} -> null with Closure: (BaseMessage) => Future<bool>
00:04 +0: loading lib/src/pubnub/e2e_test.dart                                                                                                                                           
[2021-02-22 13:20:03.461693] (info) root.pubnub.networking.request_handler: (0) Preparing request.
[2021-02-22 13:20:03.469465] (info) root.pubnub.networking.request_handler: (0) Starting request to "https://ps.pndsn.com/v2/subscribe/sub-c-62246348-xyz/ping,ptag.*/0?pnsdk=PubNub-Dart%2F3.1.0&tt=0&uuid=0a8d5c85-609c-41d3-92da-efecbfec3014"...
[2021-02-22 13:20:03.480519] (verbose) root.pubnub.dx.publish: Publishing a message to a channel ping
[2021-02-22 13:20:03.514954] (info) root.pubnub.networking.request_handler: (1) Preparing request.
[2021-02-22 13:20:03.515306] (info) root.pubnub.networking.request_handler: (1) Starting request to "https://ps.pndsn.com/v2/subscribe/sub-c-62246348-xyz/ping,ptag.*/0?pnsdk=PubNub-Dart%2F3.1.0&tt=0&uuid=b041e791-44f1-4f43-87b9-65389dc218af"...
[2021-02-22 13:20:03.515838] (info) root.pubnub.networking.request_handler: (2) Preparing request.
[2021-02-22 13:20:03.516139] (info) root.pubnub.networking.request_handler: (2) Starting request to "https://ps.pndsn.com/publish/pub-c-f1746312-xxx/0/ping/0/%7B%22message%22:%22This%20is%20a%20ping...%22,%22kind%22:%22ping%22,%22requestId%22:%227062225e-6cd2-48a6-9a01-f019eccbcb9c%22%7D?pnsdk=PubNub-Dart%2F3.1.0&uuid=b041e791-44f1-4f43-87b9-65389dc218af&timestamp=1614028803&signature=v2.S1wUwlUOWKA4FhhRjRD8p7E6S_WfvEfEFPNvxMshhws"...
[2021-02-22 13:20:03.763712] (info) root.pubnub.networking.request_handler: (2) Request succeed!
[2021-02-22 13:20:03.774616] (info) root.pubnub.networking.request_handler: (2) Resource released...
00:04 +0: E2E                                                                                                                                                                            
### PR: Sent false
00:04 +0: loading lib/src/pubnub/e2e_test.dart                                                                                                                                           
[2021-02-22 13:20:03.785144] (info) root.pubnub.networking.request_handler: (0) Request succeed!
[2021-02-22 13:20:03.785542] (info) root.pubnub.networking.request_handler: (0) Resource released...
[2021-02-22 13:20:03.786840] (silly) root.pubnub.subscribe.subscribe_loop: Result: timetoken 16140288037329192, new messages: 0
[2021-02-22 13:20:03.790669] (silly) root.pubnub.subscribe.subscribe_loop: Updating the state...
[2021-02-22 13:20:03.791009] (silly) root.pubnub.subscribe.subscribe_loop: State has been updated.
[2021-02-22 13:20:03.796038] (silly) root.pubnub.subscribe.subscribe_loop: Starting new loop iteration.
[2021-02-22 13:20:03.796599] (info) root.pubnub.networking.request_handler: (3) Preparing request.
[2021-02-22 13:20:03.796866] (info) root.pubnub.networking.request_handler: (3) Starting request to "https://ps.pndsn.com/v2/subscribe/sub-c-62246348-xyz/ping,ptag.*/0?pnsdk=PubNub-Dart%2F3.1.0&tt=16140288037329192&tr=1&uuid=0a8d5c85-609c-41d3-92da-efecbfec3014"...
[2021-02-22 13:20:03.798107] (info) root.pubnub.networking.request_handler: (1) Request succeed!
[2021-02-22 13:20:03.798439] (info) root.pubnub.networking.request_handler: (1) Resource released...
[2021-02-22 13:20:03.798859] (silly) root.pubnub.subscribe.subscribe_loop: Result: timetoken 16140288037329192, new messages: 0
[2021-02-22 13:20:03.799151] (silly) root.pubnub.subscribe.subscribe_loop: Updating the state...
[2021-02-22 13:20:03.799253] (silly) root.pubnub.subscribe.subscribe_loop: State has been updated.
[2021-02-22 13:20:03.799744] (silly) root.pubnub.subscribe.subscribe_loop: Starting new loop iteration.
[2021-02-22 13:20:03.800134] (info) root.pubnub.networking.request_handler: (4) Preparing request.
[2021-02-22 13:20:03.800382] (info) root.pubnub.networking.request_handler: (4) Starting request to "https://ps.pndsn.com/v2/subscribe/sub-c-62246348-xyz/ping,ptag.*/0?pnsdk=PubNub-Dart%2F3.1.0&tt=16140288037329192&tr=1&uuid=b041e791-44f1-4f43-87b9-65389dc218af"...
00:32 +0 -1: E2E [E]                                                                                                                                                                     
  TimeoutException after 0:00:30.000000: Test timed out after 30 seconds. See https://pub.dev/packages/test#timeouts
  dart:isolate  _RawReceivePortImpl._handleMessage
  

This is the good log:

[2021-02-22 13:23:14.697679] (silly) root.pubnub.subscribe.subscribe_loop: State has been updated.
[2021-02-22 13:23:14.702212] (verbose) root.pubnub.subscription.subscription: Resuming subscription.
[2021-02-22 13:23:14.702847] (silly) root.pubnub.subscribe.subscribe_loop: State has been updated.
[2021-02-22 13:23:14.704387] (silly) root.pubnub.subscribe.subscribe_loop: Starting new loop iteration.
00:01 +0: E2E                                                                                                                                                                            
SUB:  false false
00:01 +0: loading lib/src/pubnub/e2e_test.dart                                                                                                                                           
[2021-02-22 13:23:14.707125] (silly) root.pubnub.subscribe.subscribe_loop: State has been updated.
[2021-02-22 13:23:14.707202] (verbose) root.pubnub.subscription.subscription: Resuming subscription.
[2021-02-22 13:23:14.707292] (silly) root.pubnub.subscribe.subscribe_loop: State has been updated.
[2021-02-22 13:23:14.709022] (silly) root.pubnub.subscribe.subscribe_loop: Starting new loop iteration.
00:01 +0: E2E                                                                                                                                                                            
SUB:  false false
==>: Instance of 'Ping' {message: This is a ping..., kind: ping} -> null with Closure: (BaseMessage) => Future<bool>
00:03 +0: loading lib/src/pubnub/e2e_test.dart                                                                                                                                           
[2021-02-22 13:23:16.719123] (info) root.pubnub.networking.request_handler: (0) Preparing request.
[2021-02-22 13:23:16.723769] (info) root.pubnub.networking.request_handler: (0) Starting request to "https://ps.pndsn.com/v2/subscribe/sub-c-62246348-xyz/ping,ptag.*/0?pnsdk=PubNub-Dart%2F3.1.0&tt=0&uuid=3fbaa4e7-3bd4-423f-93ec-201aafa97ec4"...
[2021-02-22 13:23:16.731893] (verbose) root.pubnub.dx.publish: Publishing a message to a channel ping
[2021-02-22 13:23:16.765832] (info) root.pubnub.networking.request_handler: (1) Preparing request.
[2021-02-22 13:23:16.766196] (info) root.pubnub.networking.request_handler: (1) Starting request to "https://ps.pndsn.com/v2/subscribe/sub-c-62246348-xyz/ping,ptag.*/0?pnsdk=PubNub-Dart%2F3.1.0&tt=0&uuid=f14bece7-3d07-4be1-87b7-a9e81e0aaad5"...
[2021-02-22 13:23:16.766768] (info) root.pubnub.networking.request_handler: (2) Preparing request.
[2021-02-22 13:23:16.767072] (info) root.pubnub.networking.request_handler: (2) Starting request to "https://ps.pndsn.com/publish/pub-c-f1746312-xyz/sub-c-62246348-xyz/0/ping/0/%7B%22message%22:%22This%20is%20a%20ping...%22,%22kind%22:%22ping%22,%22requestId%22:%22a39ff9c2-620e-4709-8616-f4358bb5110b%22%7D?pnsdk=PubNub-Dart%2F3.1.0&uuid=f14bece7-3d07-4be1-87b7-a9e81e0aaad5&timestamp=1614028996&signature=v2.ZNOgTei66JYijwxin_j8l_Pb35rJ_FMWwyxsrRq5hG8"...
[2021-02-22 13:23:17.065199] (info) root.pubnub.networking.request_handler: (1) Request succeed!
[2021-02-22 13:23:17.076313] (info) root.pubnub.networking.request_handler: (1) Resource released...
[2021-02-22 13:23:17.083958] (silly) root.pubnub.subscribe.subscribe_loop: Result: timetoken 16140288037329192, new messages: 0
[2021-02-22 13:23:17.087318] (silly) root.pubnub.subscribe.subscribe_loop: Updating the state...
[2021-02-22 13:23:17.087594] (silly) root.pubnub.subscribe.subscribe_loop: State has been updated.
[2021-02-22 13:23:17.091729] (silly) root.pubnub.subscribe.subscribe_loop: Starting new loop iteration.
[2021-02-22 13:23:17.092298] (info) root.pubnub.networking.request_handler: (3) Preparing request.
[2021-02-22 13:23:17.092618] (info) root.pubnub.networking.request_handler: (3) Starting request to "https://ps.pndsn.com/v2/subscribe/sub-c-62246348-xyz/ping,ptag.*/0?pnsdk=PubNub-Dart%2F3.1.0&tt=16140288037329192&tr=1&uuid=f14bece7-3d07-4be1-87b7-a9e81e0aaad5"...
[2021-02-22 13:23:17.096086] (info) root.pubnub.networking.request_handler: (0) Request succeed!
[2021-02-22 13:23:17.096529] (info) root.pubnub.networking.request_handler: (0) Resource released...
[2021-02-22 13:23:17.097039] (silly) root.pubnub.subscribe.subscribe_loop: Result: timetoken 16140288037329192, new messages: 0
[2021-02-22 13:23:17.097384] (silly) root.pubnub.subscribe.subscribe_loop: Updating the state...
[2021-02-22 13:23:17.097504] (silly) root.pubnub.subscribe.subscribe_loop: State has been updated.
[2021-02-22 13:23:17.098060] (silly) root.pubnub.subscribe.subscribe_loop: Starting new loop iteration.
[2021-02-22 13:23:17.098527] (info) root.pubnub.networking.request_handler: (4) Preparing request.
[2021-02-22 13:23:17.098813] (info) root.pubnub.networking.request_handler: (4) Starting request to "https://ps.pndsn.com/v2/subscribe/sub-c-62246348-xyz/ping,ptag.*/0?pnsdk=PubNub-Dart%2F3.1.0&tt=16140288037329192&tr=1&uuid=3fbaa4e7-3bd4-423f-93ec-201aafa97ec4"...
[2021-02-22 13:23:17.099958] (info) root.pubnub.networking.request_handler: (2) Request succeed!
[2021-02-22 13:23:17.100260] (info) root.pubnub.networking.request_handler: (2) Resource released...
00:04 +0: E2E                                                                                                                                                                            
### PR: Sent false
00:04 +0: loading lib/src/pubnub/e2e_test.dart                                                                                                                                           
[2021-02-22 13:23:17.230847] (info) root.pubnub.networking.request_handler: (3) Request succeed!
[2021-02-22 13:23:17.231245] (info) root.pubnub.networking.request_handler: (3) Resource released...
[2021-02-22 13:23:17.231776] (silly) root.pubnub.subscribe.subscribe_loop: Result: timetoken 16140289970356336, new messages: 1
00:04 +0: E2E                                                                                                                                                                            
<==: Me: f14bece7-3d07-4be1-87b7-a9e81e0aaad5 Them: f14bece7-3d07-4be1-87b7-a9e81e0aaad5 Payload: {message: This is a ping..., kind: ping, requestId: a39ff9c2-620e-4709-8616-f4358bb5110b}
--- Skipping.  Sent by us.

00:04 +0: loading lib/src/pubnub/e2e_test.dart                                                                                                                                           
[2021-02-22 13:23:17.237010] (silly) root.pubnub.subscribe.subscribe_loop: Updating the state...
[2021-02-22 13:23:17.237165] (silly) root.pubnub.subscribe.subscribe_loop: State has been updated.
[2021-02-22 13:23:17.237978] (silly) root.pubnub.subscribe.subscribe_loop: Starting new loop iteration.
[2021-02-22 13:23:17.238406] (info) root.pubnub.networking.request_handler: (5) Preparing request.
[2021-02-22 13:23:17.238707] (info) root.pubnub.networking.request_handler: (5) Starting request to "https://ps.pndsn.com/v2/subscribe/sub-c-62246348-xyz/ping,ptag.*/0?pnsdk=PubNub-Dart%2F3.1.0&tt=16140289970356336&tr=1&uuid=f14bece7-3d07-4be1-87b7-a9e81e0aaad5"...
[2021-02-22 13:23:17.243335] (info) root.pubnub.networking.request_handler: (4) Request succeed!
[2021-02-22 13:23:17.243790] (info) root.pubnub.networking.request_handler: (4) Resource released...
[2021-02-22 13:23:17.244330] (silly) root.pubnub.subscribe.subscribe_loop: Result: timetoken 16140289970356336, new messages: 1
00:04 +0: E2E                                                                                                                                                                            
<==: Me: 3fbaa4e7-3bd4-423f-93ec-201aafa97ec4 Them: f14bece7-3d07-4be1-87b7-a9e81e0aaad5 Payload: {message: This is a ping..., kind: ping, requestId: a39ff9c2-620e-4709-8616-f4358bb5110b}
###: Instance of 'Ping' {message: This is a ping..., kind: ping, requestId: a39ff9c2-620e-4709-8616-f4358bb5110b}
<<< PING: HANDLING >>>
==>: Instance of 'Pong' {message: Ponging back..., responseId: a39ff9c2-620e-4709-8616-f4358bb5110b, kind: pong} -> null with null
00:04 +0: loading lib/src/pubnub/e2e_test.dart                                                                                                                                           
[2021-02-22 13:23:17.247166] (verbose) root.pubnub.dx.publish: Publishing a message to a channel ping
[2021-02-22 13:23:17.248343] (silly) root.pubnub.subscribe.subscribe_loop: Updating the state...
[2021-02-22 13:23:17.248452] (silly) root.pubnub.subscribe.subscribe_loop: State has been updated.
[2021-02-22 13:23:17.248725] (info) root.pubnub.networking.request_handler: (6) Preparing request.
[2021-02-22 13:23:17.248969] (info) root.pubnub.networking.request_handler: (6) Starting request to "https://ps.pndsn.com/publish/pub-c-f1746312-xyz/sub-c-62246348-xyz/0/ping/0/%7B%22message%22:%22Ponging%20back...%22,%22responseId%22:%22a39ff9c2-620e-4709-8616-f4358bb5110b%22,%22kind%22:%22pong%22%7D?pnsdk=PubNub-Dart%2F3.1.0&uuid=3fbaa4e7-3bd4-423f-93ec-201aafa97ec4&timestamp=1614028997&signature=v2.HboKdqV-1QIwvUZvIDh7lSsE66x68I3YTHIjCVvxPiU"...
[2021-02-22 13:23:17.249383] (silly) root.pubnub.subscribe.subscribe_loop: Starting new loop iteration.
[2021-02-22 13:23:17.249835] (info) root.pubnub.networking.request_handler: (7) Preparing request.
[2021-02-22 13:23:17.250060] (info) root.pubnub.networking.request_handler: (7) Starting request to "https://ps.pndsn.com/v2/subscribe/sub-c-62246348-xyz/ping,ptag.*/0?pnsdk=PubNub-Dart%2F3.1.0&tt=16140289970356336&tr=1&uuid=3fbaa4e7-3bd4-423f-93ec-201aafa97ec4"...
[2021-02-22 13:23:17.628246] (info) root.pubnub.networking.request_handler: (6) Request succeed!
[2021-02-22 13:23:17.628651] (info) root.pubnub.networking.request_handler: (6) Resource released...
00:04 +0: E2E                                                                                                                                                                            
### PR: Sent false
00:04 +0: loading lib/src/pubnub/e2e_test.dart                                                                                                                                           
[2021-02-22 13:23:17.630515] (info) root.pubnub.networking.request_handler: (5) Request succeed!
[2021-02-22 13:23:17.630817] (info) root.pubnub.networking.request_handler: (5) Resource released...
[2021-02-22 13:23:17.631302] (silly) root.pubnub.subscribe.subscribe_loop: Result: timetoken 16140289976098866, new messages: 1
00:04 +0: E2E                                                                                                                                                                            
<==: Me: f14bece7-3d07-4be1-87b7-a9e81e0aaad5 Them: 3fbaa4e7-3bd4-423f-93ec-201aafa97ec4 Payload: {message: Ponging back..., responseId: a39ff9c2-620e-4709-8616-f4358bb5110b, kind: pong}
###: Instance of 'Pong' {message: Ponging back..., responseId: a39ff9c2-620e-4709-8616-f4358bb5110b, kind: pong}
--- Response received: {message: Ponging back..., responseId: a39ff9c2-620e-4709-8616-f4358bb5110b, kind: pong}

The getter 'messages' isn't defined for the class 'Future<Subscription>'.

After subscribing to a channel, the Future doesn't have a messages stream. Here's my code. pubnubChannel is a string with the name of the channel.

PubNub pubnub;
Future<Subscription> pubnubsub;
pubnub = PubNub(defaultKeyset: Keyset(subscribeKey: config.pubNubSubscribeKey));
pubnubsub = pubnub.subscribe(channels: { pubnubChannel });
pubnubsub.messages.listen((envelope) {
   print(`${envelope.uuid} sent a message: ${envelope.payload}`);
});

I'm getting this error: The getter 'messages' isn't defined for the class 'Future'.

`Subscription.messages` leaks messages

Description

Subscription.messages stream is not closed on Subscription.unsubscribe and leads to leaking messages.

Steps to reproduce:

  1. Subscribe to some channel a.
  2. Add a listener to subscription.messages stream.
  3. Unsubscribe using subscription.unsubscribe().
  4. Create new subscription to the same channel a.

Unhandled Exception: Concurrent modification during iteration: Instance of '_CompactLinkedHashSet<Subscription>'.

Topic: Push Notification
subtopic: Unsubscribe to all the subscribed channels.
Reproducable both on iOS and android.

Description: I want to unsubscribe all the channels. Hence I am using unsubscribeAll method. But it is giving the following exception -

Unhandled Exception: Concurrent modification during iteration: Instance of '_CompactLinkedHashSet'.
#0 _CompactIterator.moveNext (dart:collection-patch/compact_hash.dart:455:7)
#1 SubscribeDx.unsubscribeAll. (package:pubnub/src/dx/subscribe/subscribe.dart:53:29)

#2 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
#3 KeysetStore.forEach (package:pubnub/src/core/keyset.dart:76:12)
#4 SubscribeDx.unsubscribeAll (package:pubnub/src/dx/subscribe/subscribe.dart:52:19)

Erorr when Internet Turns off.

E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: PubNubException: request failed
    #0      new PubNubException (package:pubnub/src/core/exceptions.dart:6)
    #1      new PubNubRequestOtherException (package:pubnub/src/core/net/exceptions.dart:21)
    #2      RequestHandler.response (package:pubnub/src/net/request_handler.dart:30)
    <asynchronous suspension>
    #3      new SubscriptionManager.<anonymous closure>.<anonymous closure> (package:pubnub/src/dx/subscribe/manager/manager.dart)
    <asynchronous suspension>

Feature request: unsubscribe()

Good day,
Is it possible to add next feature:
unsubscribe()
I want to change subscription's list, but can't remove only one or few of them.
So i have to use unsubscribeAll() and make subscribe() again.

With best wishes.

Reconnect not subscribing to Object Events of the new channel

Use case: New channel added to user's Channel Group

We append the channel ID to user's channel group, and fire a reconnect, we are able to receive message, messageAction and Signal but Object Events are not received.

If we Subscribe again to the appended channel group instead of reconnect we are getting the object events as well.

So we believe something is missing or different in Reconnect, can you please verify and revert.

We are using the Null Safety version.

Not able to subscribe when running the App from Chrome.

We are having issues running our app in web version.

    PubNub pubnubInstance;

    pubnubInstance = PubNub(
      defaultKeyset: Keyset(
        subscribeKey: 'sub-k',
        uuid: UUID("some-uuid"),
      ),
    );

    pubnubSubscription = pubnubInstance.subscribe(
        channels: {"some-channel"},
        channelGroups: {'all_channels'}
    );

    pubnubSubscription.messages.listen((envelope) {
      useMessage(envelope.payload);
    });

When we subscribe to pubnub we get this error:

Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...
Debug service listening on ws://127.0.0.1:64067/_uT-RC-LZX4=/ws

Running with unsound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety
Debug service listening on ws://127.0.0.1:64067/_uT-RC-LZX4=/ws
Error: UnimplementedError
    at Object.throw_ [as throw] (http://localhost:64017/dart_sdk.js:5333:11)
    at stub.RequestHandler.new.get isCancelled [as isCancelled] (http://localhost:64017/packages/pubnub/src/networking/request_handler/stub.dart.lib.js:36:24)
    at subscribe_loop.SubscribeLoop.new._loop (http://localhost:64017/packages/pubnub/src/subscribe/subscribe_loop/subscribe_loop.dart.lib.js:146:55)
    at _loop.next (<anonymous>)
    at _AsyncStarImpl.new.runBody (http://localhost:64017/dart_sdk.js:31858:40)
    at _RootZone.runUnary (http://localhost:64017/dart_sdk.js:38888:58)
    at _FutureListener.thenAwait.handleValue (http://localhost:64017/dart_sdk.js:33874:29)
    at handleValueCallback (http://localhost:64017/dart_sdk.js:34434:49)
    at Function._propagateToListeners (http://localhost:64017/dart_sdk.js:34472:17)
    at _Future.new.[_completeWithValue] (http://localhost:64017/dart_sdk.js:34314:23)
    at async._AsyncCallbackEntry.new.callback (http://localhost:64017/dart_sdk.js:34337:35)
    at Object._microtaskLoop (http://localhost:64017/dart_sdk.js:39175:13)
    at _startMicrotaskLoop (http://localhost:64017/dart_sdk.js:39181:13)
    at http://localhost:64017/dart_sdk.js:34688:9

Flutter version: 2.0.6
Pubspec file:

name: portable_app
description: A new Flutter project.
version: 1.0.0+1

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.2
  http: ^0.13.3
  pubnub: ^3.2.0
  scoped_model: ^1.1.0
  shared_preferences: ^2.0.5

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:
  uses-material-design: true

Flutter Doctor output:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel unknown, 2.0.6, on Mac OS X 10.15.6 19G2021 darwin-x64, locale en-AL)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[!] Xcode - develop for iOS and macOS
    ! CocoaPods 1.9.1 out of date (1.10.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.0)
[✓] Connected device (1 available)

! Doctor found issues in 1 category.

Thanks in advance.

Pubnub Error at the time of internet turning OFF. (Windows Desktop)

Flutter-Channel : dev

Note : Same code works properly for Android but not working on Windows Desktop.

Flutter Doctor :

`
[√] Flutter (Channel dev, 1.26.0-1.0.pre, on Microsoft Windows [Version 10.0.18363.1016], locale en-CA)
• Flutter version 1.26.0-1.0.pre at C:\Program Files\flutter
• Framework revision 63062a6443 (8 days ago), 2020-12-13 23:19:13 +0800
• Engine revision 4797b06652
• Dart version 2.12.0 (build 2.12.0-141.0.dev)

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at C:\Users\street\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
X Android license status unknown.
Run flutter doctor --android-licenses to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.

[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.7)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
• Visual Studio Community 2019 version 16.7.30621.155
• Windows 10 SDK version 10.0.18362.0

[√] Android Studio (version 4.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.52.1)
• VS Code at C:\Users\street\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.17.0

[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.18363.1016]
• Chrome (web) • chrome • web-javascript • Google Chrome 87.0.4280.88
• Edge (web) • edge • web-javascript • Microsoft Edge 85.0.564.70

! Doctor found issues in 1 category.
`

Error is shown below.

[+98719 ms] [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PubNubException: request failed
[ +1 ms] #0 new PubNubException (package:pubnub/src/core/exceptions.dart:9:29)
[ ] #1 new PubNubRequestOtherException (package:pubnub/src/core/net/exceptions.dart:21:56)
[ ] #2 RequestHandler.response (package:pubnub/src/net/request_handler.dart:82:17)
[ +18 ms]
[ ] #3 Future.any.onValue (dart:async/future.dart)
[ ]
[ ] #0 RequestHandler.response (package:pubnub/src/net/request_handler.dart:82:11)
[ ]
[ ] #1 Future.any.onValue (dart:async/future.dart)
[ +1 ms]

Invalid device token

Hi ,

i got error when try to add push channel on IOS simulator.

PubNubException: null error: Invalid device token #0 new PubNubException (package:pubnub/src/core/exceptions.dart:9:29) #1 getExceptionFromDefaultResult (package:pubnub/src/dx/_utils/exceptions.dart:37:10) #2 getExceptionFromAny (package:pubnub/src/dx/_utils/exceptions.dart:7:12) #3 _defaultFlow (package:pubnub/src/dx/_utils/default_flow.dart:52:11) <asynchronous suspension> #4 defaultFlow.<anonymous closure> (package:pubnub/src/dx/_utils/default_flow.dart:15:21) #5 Fiber.run (package:pubnub/src/core/supervisor/fiber.dart:34:32) #6 defaultFlow (package:pubnub/src/dx/_utils/default_flow.dart:21:15) #7 PushNotificationDx.addPushChannels (package:pubnub/src/dx/push/push.dart:71:12) #8 FcmUtil.init (package:mychat_app/shared/common/fcm_util.dart:100:12) <asynchronous suspension> #9 _InitializeApplicationState.initLocalStorage.<anonymous closure>.<anonymous closure> (package:mychat_app/app_init.dart:67:19) <asynchronous suspension> #10 _InitializeApplicationState.initLocalStorage.<anonymous closure>.<anonymous closure> (package:mychat_app/app_init.dart) #11 _rootRunUnary (dart:async/zone.dart:1198:47) #12 _CustomZone.runUnary (dart:async/zone.dart:1100:19) #13 _FutureListener.handleValue (dart:async/future_impl.dart:143:18) #14 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45) #15 Future._propagateToListeners (dart:async/future_impl.dart:725:32) #16 Future._completeWithValue (dart:async/future_impl.dart:529:5) #17 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15) #18 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13) #19 Service.request (package:mychat_app/shared/db/service/service.dart) <asynchronous suspension> #20 _InitializeApplicationState.initLocalStorage.<anonymous closure> (package:mychat_app/app_init.dart:57:14) <asynchronous suspension> #21 _InitializeApplicationState.initLocalStorage.<anonymous closure> (package:mychat_app/app_init.dart) #22 new Future.delayed.<anonymous closure> (dart:async/future.dart:326:39) #23 _rootRun (dart:async/zone.dart:1182:47) #24 _CustomZone.run (dart:async/zone.dart:1093:19) #25 _CustomZone.runGuarded (dart:async/zone.dart:997:7) #26 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23) #27 _rootRun (dart:async/zone.dart:1190:13) #28 _CustomZone.run (dart:async/zone.dart:1093:19) #29 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1021:23) #30 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15) #31 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:397:19) #32 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:428:5) #33 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

my code

await pubnubApp.pubnub .addPushChannels( await _firebaseMessaging.getToken(), Platform.isIOS ? pn.PushGateway.apns2 : pn.PushGateway.gcm, channels, environment: AppConfig.appMode == 'devel' ? pn.Environment.development : pn.Environment.production, topic: 'mytopic')

flutter doctor -v

`[✓] Flutter (Channel stable, 1.22.2, on Mac OS X 10.15.7 19H2, locale en-GB)
• Flutter version 1.22.2 at /opt/flutter
• Framework revision 84f3d28555 (25 hours ago), 2020-10-15 16:26:19 -0700
• Engine revision b8752bbfff
• Dart version 2.10.2

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/md.nurfikri/Library/Android/sdk
• Platform android-30, build-tools 29.0.2
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.0.1, Build version 12A7300
• CocoaPods version 1.9.3

[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 44.0.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] IntelliJ IDEA Community Edition (version 2020.1.4)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin version 48.1.3
• Dart plugin version 201.9002

[✓] VS Code (version 1.50.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.15.1

[✓] Connected device (2 available)
• Android SDK built for x86 (mobile) • emulator-5554 •
android-x86 • Android 10 (API 29) (emulator)
• iPhone 11 Pro Max (mobile) • 8700980D-5E58-4DC4-BD02-CC06CA7FA3DE • ios
• com.apple.CoreSimulator.SimRuntime.iOS-14-0 (simulator)

• No issues found!`

pubnub dart status events

How can we listen to status events in pubnub dart ? like in the docs.
To my general question:
Pubnub is unsubscribe from channels automatically when the phone goes idle (the app is still running but in the background) - How can get event for that - client is no more subscribing so i can handle it when the phone goes back from background myself.

register to the events: pubnub.signals.networkIsConnected is not working - i try to print something on this event and disconnect from my phone wifi - package connectivity of dart is working - i get notify on it - but from pubnub listener i won't get this message

Ignore flag 'withPresence'.

Good day,
I use next code:
pubnub! .subscribe(channels: _channelsList.toSet(), withPresence: false)

After a while app catch a next message:

изображение
изображение

For some reason i have received message from Presence channel. It's provoke a enormous spam of Envelope in eventHandler.

pubnub: 3.1.0
environment:
  sdk: ">=2.12.0 <3.0.0"
  flutter: ^2.0.1

Flutter entry point (main) screen loading failed on linux device.

Flutter Version and Channel Details

  • Flutter 1.26.0-1.0.pre • channel dev • https://github.com/flutter/flutter.git
  • Framework • revision 63062a6443 (8 days ago) • 2020-12-13 23:19:13 +0800
  • Engine • revision 4797b06652
  • Tools • Dart 2.12.0 (build 2.12.0-141.0.dev)

I am facing below error when running application on linux desktop device (Ubuntu 16.04.7 LTS (xenial)). After installing last upgrade, it stops working.

[ +19 ms] Building Linux application... (completed in 27.8s)
[ +141 ms] (unoplayer:8742): Gtk-WARNING **: Error loading image 'file:///usr/share/themes/Ambiance/gtk-3.0/assets/entry.png': Unable to load
image-loading module: /snap/flutter/40/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-png.so: /lib/x86_64-linux-gnu/libz.so.1:
version ZLIB_1.2.9' not found (required by /snap/flutter/40/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/../../../libpng16.so.16) [ +3 ms] (unoplayer:8742): Gtk-WARNING **: Error loading image 'file:///usr/share/themes/Ambiance/gtk-3.0/assets/entry-disabled.png': Unable to load image-loading module: /snap/flutter/40/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-png.so: /lib/x86_64-linux-gnu/libz.so.1: version ZLIB_1.2.9' not found (required by /snap/flutter/40/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/../../../libpng16.so.16)
[ +25 ms] libEGL warning: DRI2: failed to open i965 (search paths /snap/flutter/40/usr/lib/x86_64-linux-gnu/dri)
[ +3 ms] libEGL warning: DRI2: failed to open i965 (search paths /snap/flutter/40/usr/lib/x86_64-linux-gnu/dri)
[ +30 ms] libEGL warning: DRI2: failed to open swrast (search paths /snap/flutter/40/usr/lib/x86_64-linux-gnu/dri)
[ ] libEGL warning: DRI2: failed to open swrast (search paths /snap/flutter/40/usr/lib/x86_64-linux-gnu/dri)
[ ] (unoplayer:8742): WARNING : Failed to start Flutter renderer: Failed to initialze EGL
[ ] (unoplayer:8742): Gdk-CRITICAL **: gdk_window_get_scale_factor: assertion 'GDK_IS_WINDOW (window)' failed
[ ] (unoplayer:8742): Gdk-CRITICAL **: gdk_window_get_scale_factor: assertion 'GDK_IS_WINDOW (window)' failed
[ ] (unoplayer:8742): Gdk-CRITICAL **: gdk_window_show_internal: assertion 'GDK_IS_WINDOW (window)' failed
[ +10 ms] (unoplayer:8742): Gdk-CRITICAL **: gdk_window_get_effective_parent: assertion 'GDK_IS_WINDOW (window)' failed
[ ] (unoplayer:8742): Gdk-CRITICAL **: gdk_window_move_resize_internal: assertion 'GDK_IS_WINDOW (window)' failed
[ ] (unoplayer:8742): Gdk-CRITICAL **: gdk_window_get_scale_factor: assertion 'GDK_IS_WINDOW (window)' failed
[ ] (unoplayer:8742): Gdk-CRITICAL **: gdk_window_get_position: assertion 'GDK_IS_WINDOW (window)' failed
[ ] (unoplayer:8742): Gdk-CRITICAL **: gdk_window_invalidate_maybe_recurse_full: assertion 'GDK_IS_WINDOW (window)' failed
[ +2 ms] (unoplayer:8742): Gdk-CRITICAL **: gdk_window_has_native: assertion 'GDK_IS_WINDOW (window)' failed

How to add debug logging to my pubnub client ?

In this troubleshooting docs the pubnub instance does not have log property so this code is not working:

  pubnub = PubNub(
      defaultKeyset: Keyset(
        subscribeKey: Config.pubnubSubscribeKey,
        publishKey: Config.pubnubPublishKey,
        uuid: UUID(meId),
      ),
      networking: NetworkingModule(
        retryPolicy: RetryPolicy.exponential(),
      ),
    );

    pubnub.log.level = Level.ALL;
    pubnub.onRecord.listen((record) {
      print('${record.level.name}: ${record.time}: ${record.message}');
    });

What am i missing ?

HereNow with channelGroups throws an error

Passing channelGroups to hereNow call results in an error.
I made sure the channel groups exit and contain channels.

When passing channels instead to the hereNow call, it works as expected.

Code:

_pubNub = PubNub(defaultKeyset: myKeySet);

_pubNub.hereNow(channelGroups: { myChannelGroup }, stateInfo: StateInfo.onlyUUIDs);

Error:

[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: type 'NoSuchMethodError' is not a subtype of type 'Exception'
Fiber.run (package:pubnub/src/core/supervisor/fiber.dart:41:62)
<asynchronous suspension>
defaultFlow (package:pubnub/src/dx/_utils/default_flow.dart:21:15)
PresenceDx.hereNow (package:pubnub/src/dx/presence/presence.dart:43:12)
PubNub._hereNow (package:transfable/service/pubnub.dart:129:45)
PubNub.subscribeToPresence (package:transfable/service/pubnub.dart:122:5)
InitProfile._initAdditionalServices (package:transfable/service/init_profile.dart:164:13)
InitProfile._initServices (package:transfable/service/init_profile.dart:153:5)
InitProfile.init (package:transfable/service/init_profile.dart:88:42)
_rootRunUnary (dart:async/zone.dart:1198:47)
_CustomZone.runUnary (dart:async/zone.dart:1100:19)
_FutureListener.handleValue (dart:async/future_impl.dart:143:18)
Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
Future._propagateToListeners (dart:async/future_impl.dart:725:32)
Future._completeWithValue (dart:async/future_impl.dart:529:5)
_AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
_completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
ProfileEditor.init (package:transfable/service/profile_editor.dart)
_rootRunUnary (dart:async/zone.dart:1198:47)
_CustomZone.runUnary (dart:async/zone.dart:1100:19)
_FutureListener.handleValue (dart:async/future_impl.dart:143:18)
Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
Future._propagateToListeners (dart:async/future_impl.dart:725:32)
Future._completeWithValue (dart:async/future_impl.dart:529:5)
_AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
_completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
Server.request (package:transfable/service/server/server.dart)
_rootRunUnary (dart:async/zone.dart:1198:47)
_CustomZone.runUnary (dart:async/zone.dart:1100:19)
_FutureListener.handleValue (dart:async/future_impl.dart:143:18)
Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
Future._propagateToListeners (dart:async/future_impl.dart:725:32)
Future._completeWithValue (dart:async/future_impl.dart:529:5)
_AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
_completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
Server._createRequest (package:transfable/service/server/server.dart)
_rootRunUnary (dart:async/zone.dart:1198:47)
_CustomZone.runUnary (dart:async/zone.dart:1100:19)
_FutureListener.handleValue (dart:async/future_impl.dart:143:18)
Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
Future._propagateToListeners (dart:async/future_impl.dart:725:32)
Future._complete (dart:async/future_impl.dart:519:7)
_SyncCompleter.complete (dart:async/future_impl.dart:55:12)
Future.any.onValue (dart:async/future.dart:477:45)
_rootRunUnary (dart:async/zone.dart:1198:47)
_CustomZone.runUnary (dart:async/zone.dart:1100:19)
_FutureListener.handleValue (dart:async/future_impl.dart:143:18)
Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
Future._propagateToListeners (dart:async/future_impl.dart:725:32)
Future._completeWithValue (dart:async/future_impl.dart:529:5)
_AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
_completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
DioMixin._dispatchRequest (package:dio/src/dio.dart)
_rootRunUnary (dart:async/zone.dart:1198:47)
_CustomZone.runUnary (dart:async/zone.dart:1100:19)

Accessing hidden method Lsun/misc/Unsafe;->compareAndSwapObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z (greylist, linking, allowed)

dispose() crashes app

hi, we love that Pubnub is supporting Dart/Flutter!!

pubnub: ^2.0.1
Flutter (Channel beta, 1.21.0-9.1.pre

We are seeing a crash when calling dispose() on a subscription.

_subscription = await _pubnub.subscribe(channels: {'ch1', 'ch2'});

the listener is working fine:

 _subscription.messages.listen((message) {
    print(message.payload);
 });

now try to dispose:
_subscription.dispose();

crash.

Exception has occurred.
PubNubRequestCancelException (PubNubException: request cancelled
#0      new PubNubException (package:pubnub/src/core/exceptions.dart:6:29)
#1      new PubNubRequestCancelException (package:pubnub/src/core/net/exceptions.dart:14:9)
#2      RequestHandler.response (package:pubnub/src/net/request_handler.dart:65:17)
<asynchronous suspension>
#3      new SubscriptionManager.<anonymous closure> (package:pubnub/src/dx/subscribe/manager/manager.dart:63:14)
#4      CallbackEffect.execute (package:pubnub/src/state_machine/effects/callback.dart:34:13)
#5      StateMachine._report (package:pubnub/src/state_machine/state_machine.dart:53:14)
#6      StateMachine._transition (package:pubnub/src/state_machine/state_machine.dart:80:5)
#7      StateMachine.send (package:pubnub/src/state_machine/state_machine.dart:109:5)
#8      new SubscriptionManager.<anonymous closure>.<anonymous closure> (package:pubnub/src/dx/subscribe/manager/manager.dart:58:23)
#9      _rootRunUnary (dart:async/zone.dart:1198:47)
#10     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#11     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#12     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#13     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#14     Future._completeWithValue (dart:async/future_impl.dart:529:5)
#15     Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:567:7)
#16     _rootRun (dart:async/zone.dart:1190:13)
#17     _CustomZone.run (dart:async/zone.dart:1093:19)
#18     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
#19     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
#20     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#21     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
 )

[✓] Flutter (Channel beta, 1.21.0-9.1.pre, on Mac OS X 10.15.5 19F101, locale en-AU)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.0)
[✓] VS Code (version 1.48.2)

can't get package pubnub

please i need some help to fix this error.
pubnub: ^3.2.0
or
pubnub: any

[pubnub] flutter pub get
Running "flutter pub get" in pubnub...                          
Error on line 25, column 3 of pubspec.yaml: A package may not list itself as a dependency.

   ╷


25 │   pubnub: ^3.2.0
   │   ^^^^^^

   ╵
pub get failed (65;    ╵)
exit code 65

`addMessageAction` throws PubNubException: 400 error: No JSON payload

Simple code for adding message actions was working fine on PubNub 3.0.2, stopped working on newer versions (checked on (3.1.0 and 3.2.0)

_pubNub.addMessageAction(
  'report',
  'report',
  _messagesChannel,
  Timetoken(timetoken),
);

Stacktrace:

[VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: PubNubException: 400 error: No JSON payload
#0      new PubNubException (package:pubnub/src/core/exceptions.dart:9:29)
#1      getExceptionFromDefaultResult (package:pubnub/src/dx/_utils/exceptions.dart:41:10)
#2      getExceptionFromAny (package:pubnub/src/dx/_utils/exceptions.dart:7:12)
#3      _defaultFlow (package:pubnub/src/dx/_utils/default_flow.dart:82:11)
<asynchronous suspension>
#4      defaultFlow.<anonymous closure> (package:pubnub/src/dx/_utils/default_flow.dart:18:19)
#5      Fiber.run (package:pubnub/src/core/supervisor/fiber.dart:37:32)
#6      defaultFlow (package:pubnub/src/dx/_utils/default_flow.dart:27:15)
#7      MessageActionDx.addMessageAction (package:pubnub/src/dx/message_action/message_action.dart:86:12)
<asynchronous suspension>
#8      _MyHomePageState.build.<anonymous closure>.<anonymous closure> (package:pubnub_meta_demo/main.dart:124:41)
#9      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dar<…>

PubNub version: 3.2.0 and 3.1.0
Flutter 1.22.6
Example code

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.