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 revenue for your application.

1. Initialization

SDK Initialization best practices:

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.

CoroutineScope(Dispatchers.Main).launch {
    Tyrads.getInstance().init(
        context,
        apiKey: "xyz",
        apiSecret:"abc123",
        encryptionKey:"qwet",
        engagementId = 333",
        config = TyradsConfig(
            skipInitialPages = true
        ),
    );
}

encryptionKey: This would be used for encrypting data transmitted from the SDK. If not provided, data will be transmitted plain form.

engagementId: (New) Optional engagement identifier to associate SDK activity with specific user engagements or campaigns.

config: (New) Configuration object (TyradsConfig) to customize SDK behavior. For example, skipInitialPages a Boolean (true or false) can be set dynamically. The skipInitialPages option in the TyradsConfig allows your app to bypass certain introductory pages during SDK initialization. When set to true, the SDK will skip the Privacy and Terms & Conditions page as well as the Usage Permission page, allowing users to enter directly into the main app experience without having to manually navigate through these consent or informational screens.

1.1 Advanced Practices for initialization for personalized rewards

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

CoroutineScope(Dispatchers.Main).launch {
    val userInfo = TyradsUserInfo(
        email = "[email protected]",
        phoneNumber = "0987653211223",
        userGroup = "High purchase user"
    )
    val mediaSourceInfo = TyradsMediaSourceInfo(
        mediaSourceName = "Facebook",
        mediaCampaignName = "Summer Sale",
        mediaSourceId = "123",
        mediaSubSourceId = "A1",
        incentivized = true,
        mediaAdsetName = "AdSet1",
        mediaAdsetId = "AS123",
        mediaCreativeName = "CreativeBanner",
        mediaCreativeId = "CB123",
        sub1 = "user123",
        sub2 = "app_launch",
        sub3 = "variantA",
        sub4 = "regionX",
        sub5 = "extraInfo"
    )
    Tyrads.getInstance().setMediaSourceInfo(mediaSourceInfo)
    Tyrads.getInstance().setUserInfo(userInfo)
    Tyrads.getInstance().init(
        context,
        apiKey: "xyz",
        apiSecret:"abc123",
        encryptionKey:"qwet",
        engagementId = 333",
        config = TyradsConfig(
            skipInitialPages = true
        ),
    );
}
  • Always call setMediaSourceInfo or setUserInfo immediately prior (before) to SDK loginUser or just after init to ensure all campaign metadata is tracked from session start.

  • If certain fields in the TyradsMediaSourceInfo or TyradsUserInfo class are not needed, simply omit them from your object creation—these fields will remain null by default and can be ignored unless explicitly set. There is no need to assign null manually; unassigned parameters will default automatically.

Sending Media Source Data

Sending User Segments / User Info

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.

CoroutineScope(Dispatchers.Main).launch {
    Tyrads.getInstance().loginUser(
        userID: "xxx"
    );//userID is optional
} 

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. The offerwall is where users can engage with various offers, advertisements, or promotions provided by Tyrads, potentially earning rewards or incentives in the process.

CoroutineScope(Dispatchers.Main).launch {
    Tyrads.getInstance().showOffers();
}

Last updated