Build

All PubNub SDKs Now Require Unique Identifiers (UUIDs)

2 min read Keith Lindsay on Mar 4, 2022
Try PubNub Today

Free up to 1MM monthly messages. No credit card required.

Subscribe to our newsletter

By submitting this form, you are agreeing to our Terms and Conditions and Privacy Policy.

PubNub SDKs now require UUIDs, which will enable developers to make better use of their user data to enhance their apps and improve the user experience.

The cautionary tale

Our tale begins with a developer trying to rush to prototype their chat application, they found PubNub so easy to get started they skimmed over the documentation and didn’t realize that unique identifiers for each of their application instances would be generated every time the application started.

Being on the MAU pricing plan, which charges for each user, this was a recipe for disaster. Their bill ballooned far beyond their actual usage. If only they had set the UUIDs in their application instead of using the default random ID generator.

The solution

After hearing this cautionary tale, our team decided to fix this problem by enforcing our best practice policy of requiring the UUID to be set. Previously, if a UUID was not set, PubNub SDKs would randomly generate on when connection was created to PubNub. Often, this would inflate the user numbers and cause customers to be billed more than our actual usage. 

Now when our developer tries to implement PubNub without setting the UUID, they will get an error until they generate one. This allows them to identify each user in their own unique way and ensure that events and messages generated by the user are published to the correct channels.

Identity is one of the key components of a Virtual Space, so by requiring our developers to uniquely identify each, we empower them to utilize the data generated by each user to enhance their application and deliver the best experience to their end users. 

How do you generate your own unique identifier?

Every program language has built in id generators that can be used, however, one of the most common ways to create an identifier for a specific device is to create a hash of something unique to the device. For example, as long as it can’t be reversed, hashing the MAC address of the device or the email address of the user can be a good way to generate a unique identifier that is always associated with the device or the user.

To generate a UUID for each language, you can visit this page. And if you're not already building with PubNub but are looking to get started, you can try our APIs for free here.

More from PubNub

Comparing Game Engines: Unity vs Unreal vs the Rest
Real-Time Gaming BlogSep 21, 20225 min read

Comparing Game Engines: Unity vs Unreal vs the Rest

Comparing the major game engines: Unity vs Unreal Engine vs Corona SDK vs GameMaker Studio, including the benefits and cons of...

PubNub Staff

PubNub Staff

Python Socket Programming: Client, Server and Peer Libraries
BuildSep 21, 20226 min read

Python Socket Programming: Client, Server and Peer Libraries

Sockets (aka socket programming) enable programs to send and receive data, bi-directionally, at any given moment. This tutorial...

PubNub Staff

PubNub Staff

Node.js WebSocket Programming Examples
BuildSep 21, 20226 min read

Node.js WebSocket Programming Examples

An overview and examples of basic socket and WebSocket programming with Node.js.

PubNub Staff

PubNub Staff