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

How to Add a Notification Badge to Icons in React Native
Real-time Chat BlogDec 19, 20226 min read

How to Add a Notification Badge to Icons in React Native

Display real-time notification badges with PubNub and React Native to display important information and bring users back to your...

Michael Carroll

Michael Carroll

Digital Twins and the Future of Real-Time Data
InsightsDec 6, 20224 min read

Digital Twins and the Future of Real-Time Data

The concept of Digital Twins has evolved over the last two decades, however, one thing remains the same: the need for real-time...

Michael Carroll

Michael Carroll

How Many Text Characters Fit in a 32KB PubNub Message?
Real-time Chat BlogNov 24, 20224 min read

How Many Text Characters Fit in a 32KB PubNub Message?

Learn the ins-and-outs of PubNub message size and get a better idea of how many text characters fit in a single message.

Michael Carroll

Michael Carroll