Adding the License Key to iOS

PSPDFKit is a commercial product and uses a license key to verify your copy against the package name you registered.

Generating the License Key

To use a PSPDFKit license with your app, you have to generate a license key and bind it to the applicationId bundle ID of your app.

  1. Log in to the PSPDFKit Portal using the credentials you received when purchasing PSPDFKit. You’ll see the list of all your purchased licenses.

  2. Locate your license (e.g. “PSPDFKit for iOS”) and click the Assign license key button next to it. A dialog will open.

  3. Enter the bundle ID of your production app. If you’re unsure about this step, please read our What Is a Bundle ID? guide first.

  4. Click next and confirm your selected bundle ID. Please double-check that the chosen identifier matches the one configured in your app, as it can no longer be changed once it’s been set.

Downloading the License Key

  1. Log in to the PSPDFKit Portal using the credentials you received when purchasing PSPDFKit. You’ll see the list of all your purchased licenses.

  2. Locate your license (e.g. PSPDFKit for iOS) and click the License Key button next to it. If there is no such button, you probably need to generate the license key first.

  3. A dialog will open showing you a code snippet with your license key.

  4. After copying the license key over to your project, the PSPDFKit SDK will be ready to use.

Using the License Key

It’s important that you set the license key before using any PSPDFKit classes:

func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
    PSPDFKit.SDK.setLicenseKey("YOUR_LICENSE_KEY_GOES_HERE")
    return true
}
- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Set your license key here. PSPDFKit is commercial software.
    // Each PSPDFKit license is bound to a specific app bundle ID.
    // Visit http://my.pspdfkit.com to get your demo or commercial license key.
    [PSPDFKitGlobal setLicenseKey:@"YOUR_LICENSE_KEY_GOES_HERE"];

    return YES;
}

If you’re using storyboards, you may have to set the license key in main.m so that it gets called even before willFinishLaunchingWithOptions:

#import <UIKit/UIKit.h>
#import "AppDelegate.h"

@import PSPDFKit;

int main(int argc, char * argv[]) {
    @autoreleasepool {
        [PSPDFKitGlobal setLicenseKey:@"YOUR_LICENSE_KEY_GOES_HERE"];
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}