For the complete documentation index, see llms.txt. This page is also available as Markdown.

3. User Login

Upon initializing the SDK, the mandatory step is to log in the user. However, passing a user ID is optional and is only necessary when the publisher operates its own user system. This login process ensures that user interactions with the offerwall are accurately tracked and attributed within the application.

LoginData loginData = new LoginData(userId: "userId"); //userID is optional
_ = await TyrSDKPlugin.Instance.LoginUserAsync(loginData);

To determine when initialization has completed, you can await the login operation and read the relevant data from the returned LoginResult:

LoginData loginData = new LoginData(userId: "userId");
LoginResult result = await TyrSDKPlugin.Instance.LoginUserAsync(loginData);

if (result.IsSuccessful)
{
    //do anything what you want after successful init...
} else
{
    // Handle unsuccessful login.
    // For example, send result.ErrorCode and result.ErrorMessage
    // to your analytics service to gain more insight into what went wrong.
}

If you don’t set a user ID in LoginUser, you can retrieve the generated user ID after successful initialization by calling the following method:

Handling Login Errors

We strongly recommend handling unsuccessful login attempts and recording the error details for troubleshooting purposes.

When a login request fails, the returned result contains the following properties:

  • ErrorCode – an error code identifying the reason for the failure.

  • ErrorMessage – a human-readable description of the error.

These values can be forwarded to your analytics and crash-reporting systems (for example, Firebase Analytics, Firebase Crashlytics, Sentry, etc.). This information can help you diagnose integration issues and provide more details when contacting support.

When LoginUserAsync fails, the returned LoginResult.ErrorCode (LoginErrorCode) tells you why:

LoginErrorCode values: None, SdkNotInitialized, MissingLoginData, MissingCredentials, AlreadyInitialized, RequestFailed, SessionRegistrationFailed, NativePluginNotInitialized, NetworkError, Timeout, AccessDenied, ResponseParsingError, ServerError.

On transient failures (NetworkError, Timeout, ResponseParsingError, ServerError) the SDK automatically retries the initialization request once after a short delay before returning a failed LoginResult. Credential/attestation rejections (AccessDenied) are never retried.

3.1 Advanced Practices for personalized rewards

To maximize the value of our Tyr SDK please follow the advanced options for user login. This will allow us to personalize the rewards for the user event further and maximize the earnings for you as publisher.

SDK Media Source Data<- For more information regarding the media source data details, please navigate this this page

Sending User Segments / User Info <- For more information regarding the userInfo and userGroup data, please navigate this this page

3.2 User Age & Gender Requirement

Before users can participate in reward activities, the SDK requires their age and gender to comply with partner requirements and properly configure available campaigns. If this information has not been provided, the SDK will automatically display a User Information page when the user opens any SDK screen that requires reward eligibility. After the data is submitted, it is stored and the page will not appear again unless the SDK state is reset.

Providing Age & Gender via API

If your application already collects age and gender, you can provide this information directly to the SDK. In this case, the User Information page will not be shown, ensuring a smoother user experience without additional prompts.

Providing user information programmatically is recommended when the application already manages user profiles or collects demographic data during onboarding.

3.3 Initialization & Authentication State

After the SDK completes its startup flow, it is important to clearly understand what “initialization” means in this context.

Although internally the SDK performs an initialization request, from a product and API perspective this step is effectively a user authentication (login) process. Once this flow completes successfully, the SDK is fully ready for use.

To allow developers to reliably verify this state, the SDK exposes a dedicated property that indicates whether the initialization/authentication process has finished successfully.

The SDK exposes an Init(...) method, but its purpose is often misunderstood is sometimes misunderstood and union with IsInitialized.

Init(...) method does not initialize the SDK. Instead, this method is responsible for configuring the SDK with the required parameters that will later be used during the authentication phase (in LoginUserAsync(...) method).

Key Notes

  • IsInitialized reflects both:

    • Successful SDK setup

    • Successful user authentication

  • A true value guarantees that:

    • All required backend requests are completed

    • The SDK is in a valid, ready-to-use state

  • A false value means:

    • Initialization/authentication is still in progress, or

    • The process has failed

Last updated