SDK
v2.0
v2.0
  • Getting Started
    • Welcome
    • Start Here
    • Postback Payout (S2S)
    • Advanced options
      • Sending Media Source Data
      • Sending User Segments / User Info
  • Unity
    • Installation
    • Initialization
    • Obtaining Adverstising ID's
  • Android
    • Prerequisite
    • Installation
    • Initialization
      • Deeplinking Routes
      • Premium Offers
    • Obtaining Adverstising ID's
  • Flutter
    • Prerequisite
    • Installation
    • Initialization
      • Deeplinking Routes
      • Premium Offers
      • changeLanguage
    • Obtaining Advertising ID's
  • REACT NATIVE
    • Prerequisites
    • Installation
    • Initialization
      • Deeplinking Routes
      • Premium Offers
    • Obtaining Advertising ID's
  • Web / Iframe
    • Initialization
    • Premium Widgets
  • Questions and troubleshooting
    • Reporting bugs
    • Known issues
    • Changelog
Powered by GitBook
On this page
  • 1. Initialization
  • 1.1 Advanced Practices for intialization for personalized rewards
  • 2. User Login
  • 3. Show Offerwall
  • Premium Offers
  • changeLanguage
  1. Flutter

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:

  • Initiate early: It's advisable to initialize the SDK promptly after your app launches to ensure that all Tyr SDK functionalities are accessible when needed.

  • Initiate post-app authentication: Re-initiate the SDK with current user details immediately after your user signs up or signs in to the app to update the userId.

  • Initiate periodically: To optimize user experience, we strongly suggest invoking this method each time your app is brought to the forefront. This shouldn't impact your app's performance noticeably.

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.

Tyrads.instance.init( apiKey: "xyz", apiSecret:"abc123");

1.1 Advanced Practices for intialization 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 intialization. This will allow us to personalize the rewards for the user event further and maximize the earnings for you as publisher.

Tyrads.instance
      .init(
        apiKey: Env.TYRADS_SDK_KEY,
        apiSecret: Env.TYRADS_SDK_SECRET,
        userInfo: TyradsUserInfo(
          email: "example@tyrads.com",
          phoneNumber: "001234567890",
          userGroup: "High purchase user",
        ),
        mediaSourceInfo: TyradsMediaSourceInfo(
          mediaSourceName: "Facebook",
          mediaCampaignName: "Summer2023Promo",
          mediaSourceId: "FB001",
          mediaSubSourceId: "FB001_Stories",
          incentivized: false,
          mediaAdsetName: "YoungAdults25-34",
          mediaAdsetId: "AD001",
          mediaCreativeName: "SummerSale_Video",
          mediaCreativeId: "CR001",
          sub1: "ReferralCode123",
          sub2: "OrganicInstall",
          sub3: "HighValueUser",
          sub4: "FirstTimeUser",
          sub5: "iOSDevice",
        ),
      );

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.

await Tyrads.instance.loginUser(userID: "xxx");//userID is optional 

The generated user ID from the SDK is based on the device identifier (GAID/OAID/IDFA)

  • If your app user resets the device identifier, your user will lose the progress data

  • If the SDK can't access the device identifier, it will generate its own device identifier and store it in the app storage. If this is the case, your app user will lose the progress data when the user uninstalls the app

  • If you send us your userId within userId field from your backened we will save this and even if the user changes their device ID we will keep their progress.

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.

Tyrads.instance.showOffers(context);
Launch Mode

Min SDK version required: v1.1.7

Works only for iOS

Tyrads SDK provides the ability to open the Offerwall in a webkit view that is embedded in the app to provide a seamless user experience. Also, it provides the ability to open the Offerwall in an external browser (Safari) if Apple's app store policy does not approve the in-app rewards system for the app.

Available launch modes:

  • launchMode: 3 - opens the Offerwall in an external browser (Safari)

  • launchMode: 2 - opens the Offerwall in a webkit view that is embedded in the app


// Note: The launchMode parameter is optional, if not specified the default would be opening the Offerwall in an external browser (Safari)

Tyrads.showOffers(context, launchMode: 3 );// provide launchMode: 2 to open the Offerwall in a webkit view that is embedded in the app

Usage example of showOffers with the onClose callback:

dart
Tyrads.instance.showOffers(
  context,
  // Optional parameters you can uncomment and use:
  // campaignID: 00,
  // route: TyradsDeepRoutes.CAMPAIGN_TICKETS,
  onClose: () {
    // This callback is now deprecated and is of no use.
    // This callback is triggered when the offerwall is closed.
    // Here, it simply pops the current route from the navigation stack.
    Navigator.pop(context);
  },
);

Explanation:

  • When the offerwall screen is closed, the onClose callback will be invoked.

  • In this example, Navigator.pop(context) will close the current screen and return to the previous one in the navigation stack.

Deeplinking Routes

Min SDK version required: v1.1.4

The Tyrads SDK supports deeplinking to specific sections of the offerwall. When initializing or interacting with the SDK, you can specify a route to open a particular page. For campaign-specific routes, you'll need to provide the campaignID as well.

Available routes and their usage:

  • campaigns - opens the Campaigns Page

  • campaigns-activated - opens the Activated Campaigns Page

  • campaign-details - opens the Campaign Details Page (requires campaignID)

  • campaign-tickets - opens the Campaign Tickets Page (requires campaignID)

// Note: CAMPAIGNS is the default route when no specific route is provided
Tyrads.instance.showOffers(context);

// Explicitly specifying the Campaigns Page
Tyrads.instance.showOffers(context, route: "campaigns");
//or use TyradsDeepRoutes class to avoid typos
Tyrads.instance.showOffers(context, route: TyradsDeepRoutes.CAMPAIGNS);

// Activated Campaigns Page
Tyrads.instance.showOffers(context, route: "campaigns-activated");
// or using TyradsDeepRoutes class like
Tyrads.instance.showOffers(context, route: TyradsDeepRoutes.CAMPAIGNS_ACTIVATED);

// Campaign Details Page (requires campaignID)
Tyrads.instance.showOffers(context, route: "campaign-details", campaignID: "your_campaign_id_here");
// or using TyradsDeepRoutes class like
Tyrads.instance.showOffers(context, route: TyradsDeepRoutes.CAMPAIGN_DETAILS, campaignID: "your_campaign_id_here");

// Campaign Tickets Page (requires campaignID)
Tyrads.instance.showOffers(context, route: "campaign-tickets", campaignID: "your_campaign_id_here");
// or using TyradsDeepRoutes class like
Tyrads.instance.showOffers(context, route: TyradsDeepRoutes.CAMPAIGN_TICKETS, campaignID: "your_campaign_id_here");

Premium Offers

This method returns a pre-built Flutter widget that displays a list of top offers. It provides several customization options to control the widget's appearance and behavior.

Tyrads.instance.topOffersWidget(
    context,
    showMore = true,
    showMyOffers = true,
    showMyOffersEmptyView = false,
    widgetStyle = 1
)

Parameters:

  • showMore (bool, optional): Determines whether a "Show More" button is displayed at the bottom of the widget. This button typically navigates the user to a full screen of available offers. Defaults to true.

  • showMyOffers (bool, optional): Determines whether a section displaying the user's current/claimed offers is shown within the widget. Defaults to true.

  • showMyOffersEmptyView (bool, optional): If showMyOffers is true, this determines whether a special view is displayed when the user has no current offers. This view might include a prompt to explore available offers. Defaults to false.

  • widgetStyle (int, optional): An integer value that selects a pre-defined style for the widget. Different style values might change the widget's layout, color scheme, or other visual aspects. Defaults to 1.

Available Widget Style options

Return Value:

  • Widget: A Flutter Widget (specifically, a TopOffersWidget) that can be embedded in your application's UI.

Usage Example:

import 'package:tyrads_sdk/tyrads_sdk.dart';

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Offers')),
      body: Column(
        children: [
          Tyrads.instance.topOffersWidget(
            context,
            showMore: true,
            showMyOffers: true,
            widgetStyle: 2,
          ),
          // ... other widgets
        ],
      ),
    );
  }
}

changeLanguage

This asynchronous method allows you to change the language used by the Tyrads SDK. It updates the SDK's internal locale settings.

Tyrads.instance.changeLanguage("en");

Parameters:

  • languageCode (String): A string representing the desired language code (e.g., "en" for English, "es" for Spanish, "fr" for French). This should be a valid ISO 639-1 language code.

  • supported Languages: English (en), Spanish (es), Indonesian (id), Japanese (ja) and Korean (ko)

Usage Example:

import 'package:tyrads_sdk/tyrads_sdk.dart';

ElevatedButton(
  onPressed: () {
    Tyrads.instance.changeLanguage('es'); // Change to Spanish
  },
  child: Text('Change to Spanish'),
),

Notes:

  • This method persists the selected language in shared preferences so that it persists between app sessions.

  • Make sure your application and the Tyrads SDK support the language code you are passing, otherwise english will be set.

  • This method is asynchronous because it involves writing to shared preferences.

  • Consider providing a language selection UI in your application that allows users to choose their preferred language if not Sdk itself provides user to select prefered language.

PreviousInstallationNextDeeplinking Routes

Last updated 16 days ago

Option 1
Option 2
Option 3
Option 4