Initialization

Integrating the TyrAds offerwall functionality into your application is a straightforward process that involves a few key steps. By following these integration steps, you can seamlessly incorporate the offerwall feature, enhancing user engagement and potentially generating additional revenue for your application.

SDK Initialization best practices:

For guidance on integrating TyrSDK - including proper initialization and offer display - see the example at:

Assets/Plugins/TyrAdsSDK/Examples

1. Scene setup

Add the TyrSDKPlugin prefab to your initial scene:

Assets/Plugins/TyrAdsSDK/Prefabs/TyrSDKPlugin.prefab

This enables API access via SDKPlugin.Instance in code.

1. Initialization

This step initializes the Tyrads SDK within your application. You need to provide the API key and API secret obtained from the Tyrads platform. This allows your app to communicate securely with Tyrads' servers.

a. Adding Credentials via the Editor

Once TyrSDK is imported, follow these steps to configure it for your project:

  • Open the Configuration Window

    • Navigate to TyrSDK > TyrSDK Settings to access the TyrSDK Settings panel.

  • Enter Your Credentials

    • API Key: A 32-character hexadecimal string.

    • API Secret: A 92-character hexadecimal string.

    • Encryption Key: A 32-character hexadecimal string.

b. Adding Credentials via the Code

Make a call:

TyrSDKPlugin.Instance.Init("API_KEY", "API_SECRET", "ENCRYPTION_KEY");

before making a LoginUser call. This ensures that your credentials are properly set before the initialization process begins.

2. 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.

TyrSDKPlugin.Instance.LoginUser(userId); //userID is optional

To receive the initialization completion result, subscribe to the event before calling LoginUser:

TyrSDKPlugin.Instance.InitializationCompleted += OnSdkInitializationCompleted;

...

private void OnSdkInitializationCompleted(bool isSuccess)
{
    // your code here
}

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:

var userId = TyrSDKPlugin.Instance.GetUserId();

3. Show Offerwall

Once the SDK is initialized and the user is logged in (if applicable), you can display the offerwall to the user. This typically involves calling a function provided by the Tyrads SDK, such as showOffers, passing in the context of your application. The offerwall is where users can engage with various offers, advertisements, or promotions provided by Tyrads, potentially earning rewards or incentives in the process.

TyrSDKPlugin.Instance.ShowOffers();

Last updated