Skip to main content

Getting Started

Pre-requisites

Install a Perl distribution (ie Strawberry Perl) and ensure perl.exe is in your path.

Android SDK/NDK Versions

The mod.io Android SDK is built against NDK version r25b and supports the arm64-v8a ABI. To install the correct NDK, open Android Studio, go to the SDK Manager and install the following:

  • SDK Platforms
    • Android 14.0 ("UpsideDownCake") (API 34)
  • SDK Tools (tick Show Package Details to see all these)
    • Android SDK Build Tools - 34.0.0
    • NDK - 25.1.8937393
    • Android SDK Command-line Tools - latest
    • CMake 3.22.1

Compiling for Android

Currently, the mod.io SDK can only be used from native Android applications being built with CMake on Windows. There is no support for the AGDE for Visual Studio. mod.io SDK method calls are not available from Java. You can follow the CMake Integration documentation for how to configure your native CMake project to use the SDK.

Initializing the Android SDK

Prior to initializing the mod.io SDK via Modio::InitializeAsync, you have to pass a few initialization parameters to the SDK for Android specific support.

  1. #include "ModioAndroid.h". The next three android specific function calls require this header.

  2. Pass mod.io the JNI VM and an optional reference to the global ClassLoader using Modio::InitializeAndroidJNI(vm, nullptr);. Generally you should do this in your JNI_OnLoad method. If you don't provide a reference to the native classloader, the SDK will attempt to discover and create one itself.

  3. Pass mod.io a reference to your native main Activity using Modio::SetGlobalActivity(JavaObject);. You can do this either in a native event from Java, or anytime in your startup process if you have a reference to the native activity cached.

  4. Call Modio::InitializeAndroid(); for mod.io to initialize and setup its JNI bindings.

Authentication

Authentication on Meta Quest requires three key pieces of information:

  • Access Token
  • User Proof (Nonce)
  • User ID

Here's how to obtain these credentials:

std::string UserProofResponseString;
std::string AccessTokenResponseString;

// Handle oculus messages in your game loop
{
ovrMessageHandle message = ovr_PopMessage();

while (message)
{
ovrMessageType messageType = ovr_Message_GetType(message);

if (messageType == ovrMessage_User_GetUserProof)
{
if (!ovr_Message_IsError(message))
{
ovrUserProofHandle result = ovr_Message_GetUserProof(message);
UserProofResponseString = ovr_UserProof_GetNonce(result);
}
else
{
ovrErrorHandle Error = ovr_Message_GetError(message);
// Handle error
}
}
else if (messageType == ovrMessage_User_GetAccessToken)
{
if (!ovr_Message_IsError(message))
{
AccessTokenResponseString = ovr_Message_GetString(message);
}
else
{
ovrErrorHandle Error = ovr_Message_GetError(message);
// Handle error
}
}

ovr_FreeMessage(message);
message = ovr_PopMessage();
}
}

// Query Meta SDK for the User Proof
ovr_User_GetUserProof();

// Query Meta SDK for the Access Token
ovr_User_GetAccessToken();

// Get the User ID
std::string UserIdString = std::to_string(ovr_GetLoggedInUserID());

Once you have these credentials, authenticate with mod.io:

Modio::AuthenticationParams AuthParams;
AuthParams.bUserHasAcceptedTerms = false;
AuthParams.AuthToken = AccessTokenResponseString;
AuthParams.UserEmail = "example@gmail.com";
AuthParams.ExtendedParameters[Modio::Detail::Constants::APIStrings::Device] = "quest"; // Use "rift" for Oculus Rift
AuthParams.ExtendedParameters[Modio::Detail::Constants::APIStrings::Nonce] = UserProofResponseString;
AuthParams.ExtendedParameters[Modio::Detail::Constants::APIStrings::UserID] = UserIdString;

Modio::AuthenticateUserExternalAsync(AuthParams, Modio::AuthenticationProvider::Oculus, [](Modio::ErrorCode ec) {
// Handle authentication result
});