Subscription API

Introduction

The Subscription APIs are able to tell if the user is a subscriber. Through the APIs, you can provide some different specific services to the subscriber if needed.

Note

Subscription APIs are supported on PC and Mobile platforms.

Function Spec

void IsReady(StatusCallback callback)

API Parameters:

Name Class Description
callback StatusCallback callback function

For Unity

SubscriptionStatus GetUserStatus();

API Return: SubscriptionStatus

Value Description
Platforms Platforms that the user has subscribed to, such as Windows or Android.
Type The user’s Transaction Type in VIVEPORT INFINITY.

Platforms: enum

Value Description
Windows The user is a Windows subscriber in VIVEPORT.
Android The user is an Android subscriber in VIVEPORT.

Type: enum

Value Description
UNKNOWN If the user is not a subscriber to any platforms, this value will be UNKNOWN.
PAID This user is a paid subscriber
REDEEM This user is a redeem subscriber
FREE_TRIAL This user is a free trial subscriber

For Unreal

bool IsWindowsSubscriber();

API Return: bool

Value Description
true The user is a Windows subscriber in VIVEPORT.
false The user is NOT a Windows subscriber.
bool IsAndroidSubscriber();

API Return: bool

Value Description
true The user is an Android subscriber in VIVEPORT.
false The user is NOT an Android subscriber.
SubscriptionTransactionType GetTransactionType();

API Return: SubscriptionTransactionType

Value Description
UNKNOWN If the user is not a subscriber to any platforms, this value will be UNKNOWN.
PAID This user is a paid subscriber
REDEEM This user is a redeem subscriber
FREE_TRIAL This user is a free trial subscriber

Details

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

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

Best Practice

Attention

  • Get a VIVEPORT ID and VIVEPORT Key correctly from the VIVEPORT developer console.
  • 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 Subscription API - Viveport.Subscription.IsReady to ensure the connection is successfully established with the VIVEPORT platform.
  • Use Subscription API - Viveport.Subscription.IsWindowsSubscriber to determine if the user is a Windows subscriber in VIVEPORT INFINITY.
  • Use Subscription API - Viveport.Subscription.IsAndroidSubscriber to determine if the user is an Android subscriber in VIVEPORT INFINITY.
  • Use Subscription API - Viveport.Subscription.SubscriptionTransactionType to ensure the user’s Transaction Type in VIVEPORT INFINITY.
  • Use Top Level API - Viveport.Api.Shutdown to shut down 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 the 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 there. Double click to launch it and sign in with your developer account.

    _images/viveport_desktop_icon.png

Important

You can also see the Error Codes and Troubleshooting pages to know what to do whenever you encounter problems using the VIVEPORT SDK.

Sample Code

Unity / Unreal