Production licenses can be applied in one of two ways:
- Using a license string
A license string is a string of characters developers add to their application code to license their use of applications built with ArcGIS Maps SDKs for Native Apps and to unlock certain capabilities on the deployment device. . - Using a user authentication
User authentication is a type of authentication that allows users with an ArcGIS account to sign into an application and allow it to access ArcGIS content, services, and resources on their behalf. The typical authorization protocol used is OAuth2.0. workflow.
The option you choose will depend on the nature of your app and whether your app's users will sign in to your app using an ArcGIS account.
License string
A license string
Your app must include code to apply the license string. See how to use a license string in your app for more details.
Use a license string
- Users do not have an ArcGIS account with an ArcGIS Online
ArcGIS Online is a GIS mapping, analytics, data hosting, and content management software as a service (SaaS) product. It includes applications, tools, APIs, and location services for users and developers. It is subscription-based and requires an ArcGIS Online account. organization or on-premises ArcGIS EnterpriseArcGIS Enterprise is a GIS mapping, analytics, data hosting, and content management product that can be hosted on-premise or in a cloud infrastructure. It includes software, applications, tools, APIs, and services for users and developers. portal. - Your app makes use of SDK capabilities before a user signs in with their ArcGIS account.
- Your app will remain offline indefinitely, or will function if offline for a duration of more than 30 days.
Your free Lite level license string is obtained from the ArcGIS Location Platform site (sign in required). Basic, Standard, and Advanced license strings are purchased as ArcGIS Runtime license deployment packs. See get a license for more information.
A Lite license string includes unlimited production deployments.
For Basic, Standard, and Advanced license strings, the ArcGIS Runtime license deployment pack defines how many production deployments are permitted (a deployment is counted per app, install, and user).
User authentication
User authentication
Your app should allow a user to sign in using their ArcGIS account, and must include code to read and apply the license associated with their authenticated account. See how to use user authentication in your app for more information.
The administrator of the ArcGIS organization to which your app user belongs must assign a suitable ArcGIS Runtime license to your app user's ArcGIS account. See get a license for more information.
The production license obtained from user authentication travels with the user, not the app, allowing a user to license many apps.
How to use a license string in your app
You can get your production Runtime Lite license string from MyEsri. You must sign in with your ArcGIS account to retrieve your Lite license string.
You can retrieve your license string from the "ArcGIS Maps SDKs for Native Apps License Strings" card of your MyEsri dashboard's Overview page.
If you see a message that states "Your active ArcGIS Organizational account username is not enabled for esri.com websites", please contact your ArcGIS org's administrator.
Using a license string involves adding code to set the license level at compile time so that the license string is built into the application.
- Find a location in your code that runs before any SDK functionality is used.
- Call the
setLicense()method on theArcGISRuntimeEnvironmentsingleton object to license the app with a license string and any extension licenses.
The following example shows how to set a license string without extensions.
// License with a license string.
ArcGISRuntimeEnvironment.setLicense("runtimelite,1000,rud#########,day-month-year,####################");
Your app is now licensed for production use.
How to use user authentication in your app
Use of user authentication
- Find a location in your code that runs before any SDK functionality is used.
- Allow the app user to authenticate with an ArcGIS organizational account. Upon loading the
Portalobtain theLicenseInfoand use this to license the app. As part of the process, save the license information in preparation for the app being used in an offline environment for up to 30 days.
The following example shows how to get a license for an ArcGIS Online member.
// Connect to a portal with an ArcGIS account.
// The code below shows the use of token based security but
// for ArcGIS Online you should consider using Oauth credentials.
UserCredential credential = new UserCredential("user", "password");
// Replace the URL with either the ArcGIS Online URL or your ArcIGS Enterprise portal URL.
Portal portal = new Portal("https://your-org.arcgis.com");
portal.setCredential(credential);
// Load portal and listen to done loading event.
portal.loadAsync();
portal.addDoneLoadingListener(() -> {
// Check that the portal loaded correctly.
if (portal.getLoadStatus() == LoadStatus.LOADED) {
// Get license information from the portal.
ListenableFuture<LicenseInfo> licenseFuture = portal.fetchLicenseInfoAsync();
// Listen for the license info from the server.
licenseFuture.addDoneListener(() -> {
try {
LicenseInfo licenseInfo = licenseFuture.get();
// Get the license as a JSON string.
String licenseJson = licenseInfo.toJson();
// The license string will need to be stored locally for starting
// the app when there is no network connection.
// Apply the license.
ArcGISRuntimeEnvironment.setLicense(licenseInfo);
} catch (InterruptedException | ExecutionException e) {
// Error code goes here.
}
});
}
});
Your app is now licensed for production use.
If you saved the license information on local storage, your app can be started and licensed in an offline environment using the saved license information. Retrieve the license from storage and license your app.
// Get the license JSON which was stored on the device.
String storedLicense = getLicenceFromStorage();
// Generate a license info from the JSON string.
LicenseInfo licenseInfo = LicenseInfo.fromJson(storedLicense);
// License the app.
ArcGISRuntimeEnvironment.setLicense(licenseInfo);