How To Add a License Key To Your Vuforia App

来源:互联网 发布:金蝶软件购买 编辑:程序博客网 时间:2024/05/18 23:55

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.

Vuforia应用程序每个都使用从Vuforia许可证管理器获取的唯一许可证密钥。 本文将向您展示如何将密钥添加到您的Vuforia Unity,Android,iOS和UWP项目中。
If you don’t have a license key, See: Vuforia License Manager
Adding a License Key to a Unity app 将许可证密钥添加到Unity应用程序

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.

您的许可证密钥应添加到VuforiaConfiguration资产的应用许可证密钥字段,可从ARCamera的Inspector面板通过Open Vuforia Configuration按钮访问。 您还可以在“项目”面板中搜索VuforiaConfiguration。

这里写图片描述
Adding a License Key to a native iOS app

Use the setInitParameters method

1
Vuforia::setInitParameters(mVuforiaInitFlags,”“);
Example:

In SampleApplicationSession.mm of the Vuforia iOS samples

Line 132

1、将许可证密钥添加到原生iOS应用程序

使用setInitParameters方法

1
Vuforia:: setInitParameters(mVuforiaInitFlags,“”);
例:

在Vuforia iOS样品的SampleApplicationSession.mm中

第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 conditionsNSInteger 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 errorNSError * 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];}}}}

2、Adding a License Key to a native Android app

Use the setInitParameters() method:
1
Vuforia.setInitParameters(mActivity, mVuforiaFlags, ” your_license_key “);
Example:

In com.vuforia.samples.SampleApplication

File SampleApplicationSession.java

Line 336

将许可证密钥添加到本地Android应用程序

使用setInitParameters()方法:
1
Vuforia.setInitParameters(mActivity,mVuforiaFlags,“your_license_key”);
例:

在com.vuforia.samples.SampleApplication

文件SampleApplicationSession.java

第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);      }  }}

3、Adding a license key to a native UWP app

File: AppSession.cpp

将许可证密钥添加到本机UWP应用程序

文件:AppSession.cpp
这里写图片描述

原文网址:https://library.vuforia.com/articles/Solution/How-To-add-a-License-Key-to-your-Vuforia-App.html

原创粉丝点击