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);
If you do not provide a user ID, it will be generated automatically and stored in app storage. In that case, uninstalling the app will erase the ID and the user’s progress.
Preferred: supply a backend-controlled, stable user ID (or equivalent) so progress persists across reinstalls and device changes.
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
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 to the user sending us more data about the user and where they came from allow us to customize the reward experience. This can be used to provide feedback of quality of users aswell as customize the earnings journey of different segments of users.
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.
Key Notes
IsInitializedreflects both:Successful SDK setup
Successful user authentication
A
truevalue guarantees that:All required backend requests are completed
The SDK is in a valid, ready-to-use state
A
falsevalue means:Initialization/authentication is still in progress, or
The process has failed
Last updated