DRM API

Introduction

  • The VIVEPORT DRM API provides an API to verify if the current user is allowed to launch the content.

Function spec

DRM API

void GetLicense(LicenseChecker callback, string viveportId, string viveportKey);
Name Type Description
callback LicenseChecker Callback function
viveportId string entity’s VIVEPORT ID
viveportKey string entity’s VIVEPORT Key

Details

No matter whether the content is paid or free, you can use the DRM API to know if the users are allowed to launch it or not.

How to get a VIVEPORT ID and VIVEPORT key

  • Please correctly paste the VIVEPORT ID and VIVEPORT KEY of the content into your code snipped through Copy VIVEPORT ID and Copy VIVEPORT KEY buttons on the Manage -> VIVEPORT Listing page of the developer console.

    _images/AppID.png

Error code

  • It is recommended to follow the troubleshooting procedures below first if you receive an error code like the following.
Error Code Description & Troubleshooting
0 Success
50001 Invalid account ID/VIVEPORT ID/VIVEPORT key
50004 Cannot connect to the server
80002 User is not logged in to VIVEPORT account

Attention

For WAVE developers, you’ll need to modify the AndroidManifest.xml to have the permission of com.viveport.CHECK_LICENSE . You can check here for more details.

Best Practice

Attention

  • Get a VIVEPORT ID and VIVEPORT Key from the VIVEPORT Developer Console , and then paste them to your content. Please refer to here for more information.
  • Use Top Level API - Viveport.Api.Init to initialize the VIVEPORT platform. For Unity developers, the Top Level API is usually used in MonoBehaviour “Start()”.
  • Use DRM API - Viveport.Api.GetLicense to verify if the current user is allowed to launch the content. It is usually used to check the user’s authentication. If you receive an error code from the DRM API, show an error message to the user and then close the content.
  • Use Top Level API - Viveport.Api.Shutdown to shutdown and release VIVEPORT SDK resources. For Unity developers, the Top Level API is usually used in MonoBehaviour “OnDestroy()” or before Application.Quit().

Before testing

  • Go to the VIVEPORT website and download th VIVEPORT desktop application.

    _images/Viveport_home.png
  • Install the downloaded file ViveportSetup.exe and follow the step-by-step instructions to complete the setup process.

  • On the PC desktop, a VIVEPORT icon will appear. Double click to launch it and sign in with your developer account.

    _images/viveport_desktop_icon.png
  • Sign in by using a developer account. The developer account is allowed to launch its own contents by default.

  • Sign in by using another user account, and then launch the content. Because the content is not owned by the user, the authentication will fail and the Viveport.Api.GetLicense API will return an error code. At this point, you can check your error handling flow for the DRM API.

Important

You can also refer to the Error Codes and Troubleshooting pages to learn what to do when you encounter problems using the VIVEPORT SDK.

Sample Code

Notes

1.For Wave content

  • In AndroidManifest.xml, in order to use the DRM, add an element <uses-permission android:name=”com.viveport.CHECK_LICENSE” /> in <manifest> .

Example:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" ...">
<... />
<uses-permission android:name="com.viveport.CHECK_LICENSE" />
<... />
</manifest>