How to Add a License Key to Your Vuforia Engine App

This article describes how to add a license key to your Vuforia Unity, Android, iOS, and UWP projects. Vuforia Engine apps use a unique license key obtained from the Vuforia Engine License Manager.  We strongly recommend developers encrypt their key for enhanced security. To learn how to create a license key, refer to the Vuforia License Manager article.

Adding a License Key to a Unity app

After opening your Unity project, perform the following steps:

  1. In the Window menu, select Vuforia Configuration.
  2. In the Inspector window, click the Add License button. 
    The License Manager window opens in a browser.
  3. Click on your project name.
    The My License window opens.
  4. Click the license key to copy it to your clipboard.
  5. In the Inspector window, paste the key into the App License Key field. 
Vuforia Image

Adding a License Key to a native iOS app

Use the setInitParameters method

Vuforia::setInitParameters(mVuforiaInitFlags,"");

Example: In SampleApplicationSession.mm of the Vuforia iOS samples

// Initialise Vuforia
// (Performed on a background thread)
- (void)initVuforiaInBackground
{
// Background thread must have its own autorelease pool
@autoreleasepool {

Vuforia::setInitParameters(mVuforiaInitFlags," your_license_key ");

// Vuforia::init() will return positive numbers up to 100 as it progresses
// towards success.  Negative numbers indicate error conditions
NSInteger initSuccess = 0;
do {
initSuccess = Vuforia::init();
} while (0 <= initSuccess && 100 > initSuccess);

if (100 == initSuccess) {
// We can now continue the initialization of Vuforia
// (on the main thread)
[self performSelectorOnMainThread:@selector(prepareAR) withObject:nil waitUntilDone:NO];
}
else {
// Failed to initialise Vuforia:
if (Vuforia::INIT_NO_CAMERA_ACCESS == initSuccess) {
// On devices running iOS 8+, the user is required to explicitly grant
// camera access to an App.
// If camera access is denied, Vuforia::init will return
// Vuforia::INIT_NO_CAMERA_ACCESS.
// This case should be handled gracefully, e.g.
// by warning and instructing the user on how
// to restore the camera access for this app
// via Device Settings > Privacy > Camera
[self performSelectorOnMainThread:@selector(showCameraAccessWarning) withObject:nil waitUntilDone:YES];
}
else {
// Vuforia initialization error
NSError * error;
switch(initSuccess) {
case Vuforia::INIT_LICENSE_ERROR_NO_NETWORK_TRANSIENT:
error = [self NSErrorWithCode:NSLocalizedString(@"INIT_LICENSE_ERROR_NO_NETWORK_TRANSIENT", nil) code:initSuccess];
break;

case Vuforia::INIT_LICENSE_ERROR_NO_NETWORK_PERMANENT:
error = [self NSErrorWithCode:NSLocalizedString(@"INIT_LICENSE_ERROR_NO_NETWORK_PERMANENT", nil) code:initSuccess];
break;

case Vuforia::INIT_LICENSE_ERROR_INVALID_KEY:
error = [self NSErrorWithCode:NSLocalizedString(@"INIT_LICENSE_ERROR_INVALID_KEY", nil) code:initSuccess];
break;

case Vuforia::INIT_LICENSE_ERROR_CANCELED_KEY:
error = [self NSErrorWithCode:NSLocalizedString(@"INIT_LICENSE_ERROR_CANCELED_KEY", nil) code:initSuccess];
break;

case Vuforia::INIT_LICENSE_ERROR_MISSING_KEY:
error = [self NSErrorWithCode:NSLocalizedString(@"INIT_LICENSE_ERROR_MISSING_KEY", nil) code:initSuccess];
break;

default:
error = [self NSErrorWithCode:NSLocalizedString(@"INIT_default", nil) code:initSuccess];
break;

}
// Vuforia initialization error
[self.delegate onInitARDone:error];
}
}
}
}

Adding a License Key to a native Android app

Use the setInitParameters method:

Vuforia.setInitParameters(mActivity, mVuforiaFlags, " your_license_key ");

Example: In com.vuforia.samples.SampleApplication.SampleApplicationSession.java

// An async task to initialize Vuforia asynchronously.
private class InitVuforiaTask extends AsyncTask<Void, Integer, Boolean>
{
    // Initialize with invalid value:
    private int mProgressValue = -1;
    
    
    protected Boolean doInBackground(Void... params)
    {
        // Prevent the onDestroy() method to overlap with initialization:
        synchronized (mShutdownLock)
        {
          Vuforia.setInitParameters(mActivity, mVuforiaFlags, " your_license_key ");
          
          do
          {
              // Vuforia.init() blocks until an initialization step is
              // complete, then it proceeds to the next step and reports
              // progress in percents (0 ... 100%).
              // If Vuforia.init() returns -1, it indicates an error.
              // Initialization is done when progress has reached 100%.
              mProgressValue = Vuforia.init();
              
              // Publish the progress value:
              publishProgress(mProgressValue);
              
              // We check whether the task has been canceled in the
              // meantime (by calling AsyncTask.cancel(true)).
              // and bail out if it has, thus stopping this thread.
              // This is necessary as the AsyncTask will run to completion
              // regardless of the status of the component that
              // started is.
          } while (!isCancelled() && mProgressValue >= 0 && mProgressValue < 100);

          return (mProgressValue > 0);
      }
  }
}

Adding a License Key to a native UWP app

File: AppSession.cpp

void AppSession::InitAR()
 {
  const char *licenseKey = "add your key here";
  Vuforia::setInitParameters(licenseKey);    
  auto initVuforiaTask = InitVuforiaAsync();
  auto initTrackersTask = initVuforiaTask.then([this](int result) {    
      if (result < 0) {
          ThrowInitError(result);
      }        
      if (!m_appControl->DoInitTrackers()) {
          throw ref new Platform::Exception(E_FAIL, "Failed to init Trackers.");
      }
  });
 
  auto loadTrackersDataTask = initTrackersTask.then([this]() {
      if (!m_appControl->DoLoadTrackersData()) {
          throw ref new Platform::Exception(E_FAIL, "Failed to Load Tracker Data.");
      }
      m_vuforiaInitialized = true;
      m_appControl->OnInitARDone();
  });