---
agentTools:
  projectIndex: https://docs.theflyy.com/llms.txt
---

# SDK Documentation

Overview of all the SDK features available

> 📘 These docs have moved to docs.flyyx.io
>
> The latest version of this page is [Android API reference](https://docs.flyyx.io/docs/reference/android) on docs.flyyx.io. This site is no longer updated.

# **Primary Screens**

## Offers Screen

To open offers a screen for users.

[block:html]
{
  "html": "<img class=mobile-image-2 src=\"https://cdn.theflyy.com/sdk-screens/Offer_Text.png\" />\n<style>\n  img.mobile-image-2 {\n    display: block;\n    width: 33%;\n  }\n</style>"
}
[/block]

```java
Flyy.navigateToOffersActivity(context);
```
```kotlin
Flyy.navigateToOffersActivity(context)
```

## Rewards Screen

To open rewards screen for users.

[block:html]
{
  "html": "<img class=mobile-image-2 src=\"https://cdn.theflyy.com/sdk-screens/Rewards-Screen.png\" />\n"
}
[/block]

```java
Flyy.navigateToRewardsActivity(context);
```
```kotlin
Flyy.navigateToRewardsActivity(context)
```

## Wallet Screen

To open wallet screen for user.

[block:html]
{
  "html": "<img class=mobile-image-2 src=\"https://cdn.theflyy.com/sdk-screens/Wallet.png\" />\n"
}
[/block]

```java
Flyy.navigateToWalletActivity(context);
```
```kotlin
Flyy.navigateToWalletActivity(context)
```

# **Additional Screens**

## Gift Cards Screen

To open gift cards screen for user.

[block:html]
{
  "html": "<img class=mobile-image-2 src=\"https://cdn.theflyy.com/sdk-screens/Gift-Cards-Screen.png\" />"
}
[/block]

```java
Flyy.navigateToGiftCardsActivity(context);
```
```kotlin
Flyy.navigateToGiftCardsActivity(context)
```

## Referral History Screen

To open referral history screen for user.

[block:html]
{
  "html": "<img class=mobile-image-2 src=\"https://cdn.theflyy.com/sdk-screens/Referral-Tracking.png\" />"
}
[/block]

```java
Flyy.navigateToReferralHistoryActivity(context);
```
```kotlin
Flyy.navigateToReferralHistoryActivity(context)
```

## Quiz Screen

To open quiz screen for user.

[block:html]
{
  "html": "<img class=mobile-image-2 src=\"https://cdn.theflyy.com/sdk-screens/Quiz-Details.png\" />"
}
[/block]

```java
Flyy.navigateToQuizActivity(context, 0);
//live quiz_id or 0
```
```kotlin
Flyy.navigateToQuizActivity(context, 0)
//live quiz_id or 0
```

## Quiz History Screen

To open quiz history screen for user.

[block:html]
{
  "html": "<img class=mobile-image-2 src=\"https://cdn.theflyy.com/sdk-screens/Quiz_history.png\" />"
}
[/block]

```java
Flyy.navigateToQuizHistoryActivity(context);
```
```kotlin
Flyy.navigateToQuizHistoryActivity(context)
```

## Quiz List Screen

To open quiz list screen for the user.

[block:html]
{
  "html": "<img class=mobile-image-2 src=\"https://cdn.theflyy.com/sdk-screens/Quiz-Entry.png\" />"
}
[/block]

```java
Flyy.navigateToQuizListActivity(context);
```
```kotlin
Flyy.navigateToQuizListActivity(context)
```

## Stamps Screen

To open stamps screen for user.

```java
Flyy.navigateToStampActivity(context);
```
```kotlin
Flyy.navigateToStampActivity(context)
```

## Invite Detail Screen

To open the invite detail screen for user.

```java
Flyy.navigateToInviteDetailActivity(context, 2);
//offer_id can be null
```
```kotlin
Flyy.navigateToInviteDetailActivity(context, 2)
//offer_id can be null
```

## Invite And Earn Screen

To open the invite and earn screen for the user.

[block:html]
{
  "html": "<img class=mobile-image-2 src=\"https://cdn.theflyy.com/sdk-screens/Refer%20and%20Earn_Text.png\" />"
}
[/block]

```java
Flyy.navigateToInviteAndEarnActivity(context, 2);
//offer_id can be null
```
```kotlin
Flyy.navigateToInviteAndEarnActivity(context, 2);
//offer_id can be null
```

## Custom Invite and Earn Screen

To open a custom invite and earn screen for the user.

[block:html]
{
  "html": "<img class=mobile-image-2 src=\"https://cdn.theflyy.com/sdk-screens/Refer%20and%20Earn_Banner.png\" />"
}
[/block]

```java
//offer_id can be null
//tool bar items default color will be black if color is not passed
Flyy.navigateToCustomInviteAndEanActivity(context, 2, "#ffffff");
```
```kotlin
//offer_id can be null
//tool bar items default color will be black if color is not passed
Flyy.navigateToCustomInviteAndEanActivity(context, 2, "#ffffff")
```

## Challenge Details Screen

To open the challenge details screen for the user.

```java
Flyy.navigateToChallengeDetailActivity(context, 2);
//offer_id can be null
```
```kotlin
Flyy.navigateToChallengeDetailActivity(context, 2)
//offer_id can be null
```

## Bonanza Screen

To open a bonanza details screen for user.

```java
Flyy.navigateToBonanzaActivity(context);
```
```kotlin
Flyy.navigateToBonanzaActivity(context)
```

## Raffle Screen

To open the raffle details screen for the user.

```java
Flyy.navigateToRaffleDetailActivity(context, raffleId);
```
```kotlin
Flyy.navigateToRaffleDetailActivity(context, raffleId)
```

# **Additional Methods**

## Set Theme Colors

The Flyy SDK inherits theme colors which are provided to the `setThemeColor` method. The `setThemeColor` method must be called immediately after the `init` method is called.

```java
//Parameters to be passed are colorPrimary and colorPrimaryDark
Flyy.setThemeColor("#FF5733", "#842C19");
```
```kotlin
//Parameters to be passed are colorPrimary and colorPrimaryDark
Flyy.setThemeColor("#FF5733", "#842C19")
```

## Set Name

This will be shown in the screens wherever username is displayed.

```java
Flyy.setUsername("<user_name>");
```
```kotlin
Flyy.setUsername("<user_name>")
```

## SDK Initialization with referral callback

Initialize sdk in your application or main entry point of the app with referral callback as shown below.

```java
//For Production
Flyy.init(getApplicationContext(), "{partner_id}", Flyy.PRODUCTION, new FlyyReferrerDataListener() {
   @Override
   public void onReferrerDataReceived(String referrerData) {
       // TODO do your work here
   }
});


//For Staging
Flyy.init(getApplicationContext(), "{partner_id}", Flyy.STAGE, new FlyyReferrerDataListener() {
   @Override
   public void onReferrerDataReceived(String referrerData) {
       // TODO do your work here
   }
});
```
```kotlin
//For Production
Flyy.init(applicationContext, "{partner_id}", Flyy.PRODUCTION, object : FlyyReferrerDataListener {
    override fun onReferrerDataReceived(p0: String?) {
        // TODO do your work here
    }
    override fun onReferralCodeWithDataReceived(p0: Array<out String>?) {
    }
})
  
//For Staging
Flyy.init(applicationContext, "{partner_id}", Flyy.STAGING, object : FlyyReferrerDataListener {
    override fun onReferrerDataReceived(p0: String?) {
        // TODO do your work here
    }
    override fun onReferralCodeWithDataReceived(p0: Array<out String>?) {
    }
})
```

## Set User Token

To increase security for your users you can set a unique user token in the following manner instead of `setUser()` method.

```java
///without callback
Flyy.setUserToken("BSt4Y3A2"); //pass your user token
```
```kotlin
///without callback
Flyy.setUserToken("BSt4Y3A2") //pass your user token
```

## Set User Token along with Segment ID

To increase security for your users you can set unique user token along with segment id in the following manner instead of **setUser()** method.

```java
//without callback
Flyy.setUserToken("BSt4Y3A2", "all_users");
```
```kotlin
//without callback
Flyy.setUserToken("BSt4Y3A2", "all_users")
```

## Set New User Token

To increase security for your users you can set unique new user token for new registered users in the following manner instead of **setNewUser()** method

```java
Flyy.setNewUserToken("QWt4Y3A2"); //pass your new user token
```
```kotlin
Flyy.setNewUserToken("QWt4Y3A2") //pass your new user token
```

## Set New User Token along with Segment ID

To increase security for your users you can set unique new user token for new registered users along with segment id  in the following manner instead of **setNewUser()** method.

```java
//without callback
Flyy.setNewUserToken("QWt4Y3A2", "all_users");
```
```kotlin
//without callback
Flyy.setNewUserToken("QWt4Y3A2", "all_users")
```

## Set Bank Details

You can use the following method to set user redemption details, which takes following params,

1. Account number - bank account number
2. IFSC code
3. Name

```java
Flyy.setBankDetails("0000xxxxxxxxxx16", "BSxxxxxxx0", "Pooja");
```
```kotlin
Flyy.setBankDetails("0000xxxxxxxxxx16", "BSxxxxxxx0", "Pooja")
```

## Set UPI Details

You can use the following method to set user redemption details, which takes following params,

1. UPI ID

```java
Flyy.setUPI("user@upiId");
```
```kotlin
Flyy.setUPI("user@upiId")
```

## Send Events

> 🚧 Sending User Event with API
>
> The `sendEvent` method should only be used for testing on the Staging environment.\
> For production, use the [Sending User Event](https://api-docs.theflyy.com/#e71f597a-a07e-4eab-875c-0ed5cd6a9626) API call from your backend instead. All `sendEvent` events generating from the front-end are ignored by the Flyy's reward system.

Values can either be sent in the form of key and value or as a json object.

```java
Flyy.sendEvent("profile_updated", "true");

//OR

Flyy.sendEvent("registration", <jsonObject>);
```
```kotlin
Flyy.sendEvent("profile_updated", "true")

//OR

Flyy.sendEvent("registration", <jsonObject>)
```

## Set Referral Code

To set referral code, please call the following function

```java
Flyy.setReferrerCode("sdfhyr6");
```
```kotlin
Flyy.setReferrerCode("sdfhyr6")
```

## Get Referral Code

To get a referral code, please call the following function

```java
Flyy.getReferrerCode();
```
```kotlin
Flyy.getReferrerCode()
```

## Verify Referral Code

To verify if referral code is valid or not, please call the following function

```java
Flyy.verifyReferralCode(this, "sdfhyr6", new FlyyVerifyReferralCode() {
   @Override
   public void isReferralCodeValid(boolean isValid, String referralCode) {
       if (isValid) {
           Log.d(TAG, "isReferralCodeValid: " + referralCode);
       }
   }
});
```
```kotlin
Flyy.verifyReferralCode(this, "sdfhyr6", object : FlyyVerifyReferralCode {
    override fun isReferralCodeValid(isValid: Boolean, referralCode: String?) {
       if (isValid) {
           Log.d(TAG, "isReferralCodeValid: " + referralCode)
       }
    }
})
```

## Show the Notification Popup

Use the below code to show a default Flyy notification popup. You can keep the notificaiton\_id and campaign\_id 0/-1 if you don't have one.

```java
Flyy.showPopup(getApplicationContext(), notification_id, "title", "message", "big_image", "deeplink", campaign_id);
```
```kotlin
Flyy.showPopup(applicationContext, notification_id, "title", "message", "big_image", "deeplink", campaign_id)
```

## Show Reward Won Popup

Use the below code to show the reward won popup.

```java
Flyy.showRewardWonPopup(
   "title", "message", "deeplink", "buttonText", showConfetti);
//showConfetti is a boolean value
```
```kotlin
Flyy.showRewardWonPopup(
   "title", "message", "deeplink", "buttonText", showConfetti)
//showConfetti is a boolean value
```

## Show Reward Won Scratch Card Popup

Use the below code to show the reward won scratch card popup.

```java
Flyy.showRewardWonScratchPopup(
   "title", "message", showConfetti, "refNum");
//showConfetti is a boolean value
```
```kotlin
Flyy.showRewardWonScratchPopup(
   "title", "message", showConfetti, "refNum")
//showConfetti is a boolean value
```

## Get Share Data

Use the below code to get share data.

```java
Flyy.getShareData(this, new FlyyReferralDataFetchedListener() {
   @Override
   public void onReferralDetailsFetched(FlyyReferralDetails referralDetails) {

   }

   @Override
   public void onFailure(String failureMessage) {

   }
});
```
```kotlin
Flyy.getShareData(this, object : FlyyReferralDataFetchedListener {
    override fun onReferralDetailsFetched(referralDetails: FlyyReferralDetails) {
        
    }
    override fun onFailure(failureMessage: String) {
        
    }
})
```

## Get Referral Count

Use the below code to get referral count.

```java
Flyy.getReferralCount(this, new FlyyReferralCountFetchedListener() {
   @Override
   public void onReferralCountFetched(int referralsCount) {
     
   }

   @Override
   public void onFailure(String failureMessage) {

   }
});
```
```kotlin
Flyy.getReferralCount(this, object : FlyyReferralCountFetchedListener {
    override fun onReferralCountFetched(referralsCount: Int) {
        
    }
    override fun onFailure(failureMessage: String) {
        
    }
})
```

## Get Scratch Card Count

Use the below code to get scratch card count.

```java
Flyy.getScratchCardCount(this, new FlyyFetchScratchCardCountListener() {
   @Override
   public void onSuccess(FlyyScrachCardCount flyyScrachCardCount) {
     
   }

   @Override
   public void onFailure(String message) {

   }
});
```
```kotlin
Flyy.getScratchCardCount(this, object : FlyyFetchScratchCardCountListener {
    override fun onSuccess(flyyScrachCardCount: FlyyScrachCardCount) {
        
    }
    override fun onFailure(message: String) {
        
    }
})
```

## Get Previous Leaderboard Winner

Use the below code to get previous leaderboard winners.

```java
//Provide tag to fetch a specific Leaderboard
Flyy.getPreviousLeaderboardWinners(this, "{tag}", new FlyyFetchLeaderboardDataListner() {
   @Override
   public void onSuccess(FlyyLeaderboardData flyyLeaderboardData) {
     
   }

   @Override
   public void onFailure(String message) {

   }
});
```
```kotlin
//Provide tag to fetch a specific Leaderboard
Flyy.getPreviousLeaderboardWinners(this, "{tag}", object : FlyyFetchLeaderboardDataListner {
    override fun onSuccess(flyyLeaderboardData: FlyyLeaderboardData) {
    
    }
    override fun onFailure(message: String) {
    
    }
```

## Get Leaderboard Participants

Use the below code to get leaderboard participants.

```java
//Provide tag to fetch a specific Leaderboard
Flyy.getLeaderboardParticipants(this, "{tag}", new FlyyFetchLeaderboardDataListner() {
   @Override
   public void onSuccess(FlyyLeaderboardData flyyLeaderboardData) {
     
   }

   @Override
   public void onFailure(String message) {

   }
});
```
```kotlin
//Provide tag to fetch a specific Leaderboard
Flyy.getLeaderboardParticipants(this, "{tag}", object : FlyyFetchLeaderboardDataListner {
    override fun onSuccess(flyyLeaderboardData: FlyyLeaderboardData) {
        
    }
    override fun onFailure(message: String) {
        
    }
})
```

## Get Wallet Balance

Use the below code to get wallet balance.

```java
Flyy.getWalletBalance(this, "Cash",  new FlyyFetchWalletDataListener() {
   @Override
   public void onSuccess(FlyySpecificWalletData flyySpecificWalletData) {
     
   }

   @Override
   public void onFailure(String message) {

   }
});
```
```kotlin
Flyy.getWalletBalance(this, "Cash", object : FlyyFetchWalletDataListener {
    override fun onSuccess(flyySpecificWalletData: FlyySpecificWalletData) {
        
    }
    override fun onFailure(message: String) {
        
    }
})
```

## Get Referrer Details

Use the below code to get referrer details.

```java
Flyy.getReferrerDetails(this, new FlyyFetchReferrerDetailsListener() {
   @Override
   public void onSuccess(FlyyReferrerDetails flyyReferrerDetails) {
     
   }

   @Override
   public void onFailure(String message) {

   }
});
```
```kotlin
Flyy.getReferrerDetails(this, object : FlyyFetchReferrerDetailsListener {
    override fun onSuccess(flyyReferrerDetails: FlyyReferrerDetails) {
        
    }
    override fun onFailure(message: String) {
        
    }
})
```

## Get Offers Count

Use the below code to get the offers count.

```java
Flyy.getOffersCount(this, new FlyyFetchOffersCountListener() {
   @Override
   public void onSuccess(FlyyOffersCount flyyOffersCount) {
      
   }

   @Override
   public void onFailure(String message) {

   }
});
```
```kotlin
Flyy.getOffersCount(this, object : FlyyFetchOffersCountListener {
    override fun onSuccess(flyyOffersCount: FlyyOffersCount) {
        
    }
    override fun onFailure(message: String) {
        
    }
})
```

# **Advanced Implementation**

## Get SDK Closed Listener

To get flyy sdk closed listener

```java
Flyy.getFlyySDKClosed(new FlyySDKClosedListener() {
   @Override
   public void onSDKClosed() {
       //do your work here
   }
});
```
```kotlin
Flyy.getFlyySDKClosed(FlyySDKClosedListener {
    //do your work here
})
```

## Add User to a Segment

To add a user to a specific segment. If you are adding a user to an existing segment, you can pass null in segment\_title. If the user segment is not present it will create a new one

```java
Flyy.addUserToSegment(segment_title, segment_key);
```
```kotlin
Flyy.addUserToSegment(segment_title, segment_key)
```

## Get Screen Visits data

Use the below code to get the following data:-

\[“home\_checkin\_clicked”, “offer\_card\_clicked”, “game\_card\_clicked”, “quiz\_card\_clicked”, “stamp\_campaign\_card\_clicked”, “leaderboard\_card\_clicked”, “checkin\_card\_clicked”, “challenges\_card\_clicked”, “raffle\_card\_clicked”, “transaction\_screen\_visited”, “detail\_checkin\_clicked”, “referrals\_screen\_visited”, “rewards\_screen\_visited”, “wallet\_screen\_visited”]

```java
Flyy.trackUIEvents(new FlyyUIEventsListener() {
   @Override
   public void onEventDone(FlyyUIEvent flyyUIEvent) {
     
   }
});
```
```kotlin
Flyy.trackUIEvents { 
    //do your work here
}
```

## Change the Confetti Colors

Use the below code to change the confetti color which gets shown when you win a ScratchCard. It will throw an IllegalArgumentException if the passed color string is incorrect.

```java
List<FlyyColor> flyyConfettiColorList = new ArrayList<>();
flyyConfettiColorList.add(new FlyyColor("#ABABAB"));
flyyConfettiColorList.add(new FlyyColor("#F0987D"));
flyyConfettiColorList.add(new FlyyColor("#BFCADE"));
Flyy.setConfettiColors(flyyConfettiColorList);
```
```kotlin
val flyyConfettiColorList: MutableList<FlyyColor> = ArrayList()
flyyConfettiColorList.add(FlyyColor("#ABABAB"))
flyyConfettiColorList.add(FlyyColor("#F0987D"))
flyyConfettiColorList.add(FlyyColor("#BFCADE"))
Flyy.setConfettiColors(flyyConfettiColorList)
```

## Set Custom Domain

Use the below code to set the custom Domain name for Flyy SDK. Ensure you do not add **https\://** with the Domain.

```java
Flyy.setBaseFlyyDomain("www.xyz.com");
Flyy.setBaseStageFlyyDomain("www.xyz.com");
```
```kotlin
Flyy.setBaseFlyyDomain("www.xyz.com")
Flyy.setBaseStageFlyyDomain("www.xyz.com")
```