Onboarding Modal

Authenticate User via Onboarding Modal

Learn how to trigger and handle authentication using the Okto Onboarding Modal in Unity.

Prerequisites

Before implementing the authentication flow, ensure you have:

Unity WebView Package

  • Download and import the Unity WebView SDK
  • This package is required for JavaScript communication between Unity and the web interface
  • Import the package through Assets > Import Package > Custom Package

Methods Overview

MethodDescription
OpenOnBoardingScreen()Opens the Okto Onboarding modal in a WebView with WhatsApp authentication

Open Onboarding Screen

OpenOnBoardingScreen() presents a guided onboarding flow to the user in a WebView. This includes WhatsApp authentication and handles the complete authentication flow.

Parameters

None. The OnboardingWebview component handles all necessary configurations internally.

Response

Success Response

Authentication success is handled through the WebView message system, which will:

  1. Receive the auth token
  2. Authenticate the user
  3. Close the WebView automatically

Environment Configuration

The WebView URL is automatically configured based on your environment setting:

private string GetBuildUrl()
{
    switch (OktoAuthExample.getOktoClientConfig().Environment.ToUpper())
    {
        case "SANDBOX":
            return "https://sandbox-onboarding.okto.tech";
        case "STAGING":
            return "https://onboarding.oktostage.com";
        default:
            return "";
    }
}

The OnboardingWebview handles:

  • WebView initialization and configuration
  • Message communication between Unity and WebView
  • WhatsApp authentication flow
  • OTP verification
  • Session management

Authentication Flow

Launch Modal

User triggers the onboarding flow through your game interface.

  • Calls OpenOnBoardingScreen()
  • Initializes WebView
  • Sets screen orientation to Portrait
  • Loads the appropriate URL based on environment
Initial Onboarding Screen

Enter Login Credentials

User inputs their email/WhatsApp number for authentication.

WhatsApp Number Input

Verify OTP

User receives and enters the OTP sent to their email/WhatsApp.

OTP Verification

Complete Authentication

System processes verification and establishes user session.

Success Screen

Important Considerations:

  • Ensure proper screen orientation handling
  • Handle WebView lifecycle appropriately
  • Implement proper error handling
  • Test across different devices and platforms