FAQ for JavaScript SDK
This page explains two behaviors of the PubNub JavaScript SDK that often surprise developers, and links to the reference page that owns each answer. The answers apply to the current SDK version.
Why does the SDK have two ways to subscribe?
The current way to subscribe creates a subscription or subscriptionSet object, attaches listeners to it, and calls subscribe() on it. You can pass a timetoken to subscribe() to resume from that point. The older pubnub.subscribe({ channels }) method remains for apps that already use it. Do not use it in new apps.
Use the current way in new code. See Subscribe. If your app still calls the older method, see Subscribe (old).
Why does a message use legacy encryption when I configure a cryptoModule?
A cipher key that you pass to a method overrides the configured crypto module for that operation and uses the legacy encryption with 128-bit cipher-key entropy. The cipher key arguments are customCipherKey for encrypt() and decrypt(), and key for encryptFile() and decryptFile().
If you want the cryptoModule to encrypt the data, remove those arguments from the call. To encrypt only part of your data, create a separate cryptoModule instance. See Relationship between cryptoModule and cipher keys and cryptoModule.