License registered for a different bundle identifier

Question: We’re seeing the following license error…

Copy
1
2
PSPDFKitError: Failed to initialize PSPDFKit: Invalid license key. Failed to activate PSPDFKit for 'example.domain'. Error: Your license has been registered for a different bundle identifier - not "example.domain".
Each PSPDFKit license is only valid for one explicit bundle ID and one distribution method (Enterprise or public App Store). Please contact sales at sales@pspdfkit.com with your requirements for a new license. PSPDFKit Web

Answer:

This error can be caused when you have both example.domain and www.example.domain licensed. Since you’re using the same license key for both domains, it can cause the error to happen intermittently, depending on whether the visitor uses www.example.domain (note: Safari simplifies the domain that’s shown to you, so unless you click on the address bar to show the full URL it might show you example.domain even though it is accessing www.example.domain.

In order to make sure you’re loading the correct license key based on the domain your users are visiting you can use something like the following:

Copy
1
2
3
4
5
6
7
8
let licenseKey = null;
if (document.location.host === "example.domain") {
  licenseKey = "<insert license key for example.domain>";
} else if (document.location.host === "www.example.domain") {
  licenseKey = "<insert license key for www.example.domain>";
} else {
  console.error("Invalid location -> escalate to ops");
}

We are working on improving this error message so it is more clear.

Additionally:

It’s generally recommend serving a web app only on one subdomain, either www or no subdomain as this can reduce potential problems. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Choosing_between_www_and_non-www_URLs for more information.