How To Add a License Key To Your Vuforia App

Vuforia apps each utilize a unique license key obtained from the Vuforia License Manager. This article will show you how to add the key to your Vuforia Unity, Android, iOS and UWP projects.

If you don't have a license key, See: Vuforia License Manager 

Adding a License Key to a Unity app

Your license key should be added to the App License Key field on the VuforiaConfiguration asset accessible from the ARCamera's Inspector panel via the Open Vuforia Configuration button. You can also search for VuforiaConfiguration in the Project panel.

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

Line 132
// 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
 
File  SampleApplicationSession.java
 
Line 336

// 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

User-added image