These docs are for v1.2.0. Click to read the latest docs for v1.2.5.

Flutter Plugin

Version:- 1.1.10

Step 1: Depend on it

Add the following line of code in your pubspec.yaml file under dependencies.

dependencies:
  flyy_flutter_plugin: ^1.1.10

Step 2: Install it

$ flutter pub get

Android Native Setup

Step 1: Add auth token

Add the following line of code in your YourProject/gradle.properties file.

authToken=jp_9lured1djkqj83p7vaqhes4img

Step 2: Add jitpack url

Add the following line of code in your project level build gradle, YourProject/build.gradle file.

allprojects {
   repositories {
       ...

       maven {
           url 'https://jitpack.io'
           credentials { username authToken }
       }
   }
}

Here ends adding dependency related to android native, sync and build your app before further integration.

iOS Native Setup

Step 1: Pod install

Navigate to the /ios folder and execute the following command to install pods.

$ pod install

Step 2: AppDelegate.swift

After successful pod installation open your ios xcworkspace project in xcode. In AppDelegate.swift inside didFinishLaunchingWithOptions method add the following line of code.

let flutterViewController: FlutterViewController = window?.rootViewController as! FlutterViewController
        self.navigationController = UINavigationController(rootViewController: flutterViewController);
        self.navigationController.setNavigationBarHidden(true, animated: false)
        self.window = UIWindow(frame: UIScreen.main.bounds)
        self.window.rootViewController = self.navigationController
        self.window.makeKeyAndVisible()

Here ends adding dependency related to flyy flutter plugin, clean and build your app before further integration.

Flutter Setup

Import

Add following line of code to import flyy plugin.

import 'package:flyy_flutter_plugin/flyy_flutter_plugin.dart'

Register Package Name

You can register the package name in Flyy Dashboard.
Go to Settings -> Connect SDK

1500

Set Package Name

You can set your package name using this method. Kindly make sure the package name should be the same as your package name given while connecting the SDK in the dashboard.

FlyyFlutterPlugin.setPackageName("<package_name_same_as_registered_in_flyy_dashboard>");

SDK Initialization

Initialize sdk in your application or main entry point of the app.

/For Production
FlyyFlutterPlugin.initFlyySDK("<partner_id>", FlyyFlutterPlugin.PRODUCTION);

//For Staging
FlyyFlutterPlugin.initFlyySDK("<partner_id>", FlyyFlutterPlugin.STAGE);

Get Partner Id

You can find the partner ID in Flyy Dashboard.
Go to Settings -> SDK Keys

1752

Set Theme Colors

Please note this is a mandatory step to set theme colors and should be done immediately after initialization of Flyy SDK.

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

Set unique User ID with and without Segment ID

To complete the initialization process, you must call either setNewUser() or setUser().

  • setNewUser() should be called only if it’s a new user.
  • setUser() should be called if the user is an existing user. Call setUser() every time the app opens to make the sdk work.
//FOR SET USER

//set user id
FlyyFlutterPlugin.setFlyyUser("unique_id");

//For SET NEW USER

//set new user id
FlyyFlutterPlugin.setFlyyNewUser("unique_id");
Note : unique_user_id can be any string which will be shown in reports, 
which must be unique and must not be changed for a User.

Set Name

This will be shown in the screens wherever username is displayed

FlyyFlutterPlugin.setFlyyUserName("<user_name>");

Offers Screen

To open offers a screen for users with or without segment id.

FlyyFlutterPlugin.openFlyyOffersPage();
                OR
FlyyFlutterPlugin.openFlyyOffersPageWithSegment("segment_id");

Rewards Screen

To open rewards screen for user

FlyyFlutterPlugin.openFlyyRewardsPage();

Wallet Screen

To open wallet screen for user

FlyyFlutterPlugin.openFlyyWalletPage();

Send FCM Token For iOS Only

Please note you will have to send us an fcm token after you do setUser or setNewUser. To send the fcm token to our server in order to start receiving flyy notifications add the following line of code after the user grants permission to receive notifications.

FlyyFlutterPlugin.sendFCMTokenToServer(value!);

Handle Background Notification For iOS

if (remoteMessage.data.containsKey("notification_source") &&
      remoteMessage.data["notification_source"] != null &&
      remoteMessage.data["notification_source"] == "flyy_sdk") {
    FlyyFlutterPlugin.handleBackgroundNotification(remoteMessage.data);
  }

Handle Foreground Notification For iOS

if (remoteMessage.data.containsKey("notification_source") &&
        remoteMessage.data["notification_source"] != null &&
        remoteMessage.data["notification_source"] == "flyy_sdk") {
      FlyyFlutterPlugin.handleForegroundNotification(remoteMessage.data);
    }

Handle Notification For Android

if (remoteMessage != null &&
   remoteMessage.data != null &&
   remoteMessage.data.containsKey("notification_source") &&
   remoteMessage.data["notification_source"] != null &&
   remoteMessage.data["notification_source"] == "flyy_sdk") {
 FlyyFlutterPlugin.handleNotification(remoteMessage.data);
}

Release FAQ’s

Proguard Rules for Android Only

If you are using proguard, please add these following rules to your proguard-rules.pro before you release the app.

#Retrofit does reflection on generic parameters. InnerClasses is required to use Signatureand
# EnclosingMethod is required to use InnerClasses.
-keepattributes Signature, InnerClasses, EnclosingMethod
# Retrofit does reflection on method and parameter annotations.
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
#Retain service method parameters when optimizing.
-keepclassmembers,allowshrinking,allowobfuscation interface * { @retrofit2.http.* <methods>;}
# Ignore annotation used for build tooling.
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
# Ignore JSR 305 annotations for embedding nullability information.
-dontwarn javax.annotation.**
# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
-dontwarn kotlin.Unit
# Top-level functions that can only be used by Kotlin.
-dontwarn retrofit2.KotlinExtensions
-dontwarn retrofit2.KotlinExtensions$*
# With R8 full mode, it sees no subtypes of Retrofit interfaces since they arecreated withaProxy
# and replaces all potential values with null. Explicitly keeping the interfacesprevents this.
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>
-keep class retrofit2.** { *; }
-keep public class theflyy.com.flyy.** {*;}

Additional Screens

Gift Cards Screen

To open gift cards screen for user

FlyyFlutterPlugin.openFlyyGiftCardsPage();

Referral History Screen

To open referral history screen for user

FlyyFlutterPlugin.openFlyyReferralsPage();

Quiz Screen

To open quiz screen for user

FlyyFlutterPlugin.openFlyyQuizPage(0);
//live quiz_id or 0

Quiz History Screen

To open quiz history screen for user

FlyyFlutterPlugin.openFlyyQuizHistoryPage();

Quiz List Screen

To open quiz list screen for user

FlyyFlutterPlugin.openFlyyQuizListPage();

Invite Detail Screen

To open the invite detail screen for user.

FlyyFlutterPlugin.openFlyyInviteDetailsPage(offer_id);
//offer_id can be null

Invite And Earn Screen

To open the invite and earn screen for the user.

FlyyFlutterPlugin.openFlyyInviteAndEarnPage(offer_id);
//offer_id can be null

Custom Invite and Earn Screen

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

FlyyFlutterPlugin.openFlyyCustomInviteAndEarnPage(offerId, "#ffffff");
//offer_id can be null
//tool bar items default color will be black if color is not passed

Challenge Details Screen

To open the challenge details screen for the user.

FlyyFlutterPlugin.openFlyyChallengeDetailsPage(offer_id);
//offer_id can be null

Bonanza Screen

To open a bonanza details screen for user.

FlyyFlutterPlugin.openFlyyBonanzaPage();

Additional Methods

SDK Initialization with referral callback

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

//For Production
String referrerData = await FlyyFlutterPlugin.initFlyySDKWithReferralCallback("<partner_id>", FlyyFlutterPlugin.PRODUCTION);


//For Staging
String referrerData = await FlyyFlutterPlugin.initFlyySDKWithReferralCallback("<partner_id>", FlyyFlutterPlugin.STAGE);

Set User Token

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

//without callback
FlyyFlutterPlugin.setFlyyUserToken("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

//without callback
FlyyFlutterPlugin.setFlyyUserTokenWithSegment("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

FlyyFlutterPlugin.setFlyyNewUserToken("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

//without callback
FlyyFlutterPlugin.setFlyyNewUserTokenWithSegment("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
FlyyFlutterPlugin.setBankDetails("0000xxxxxxxxxx16", "BSxxxxxxx0", "user name");

Set UPI Details

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

  1. UPI ID
FlyyFlutterPlugin.setUpiDetails("user@upiId");

Set Referral Code

To set referral code, please call the following function

FlyyFlutterPlugin.setFlyyReferralCode("sdfhyr6");

Get Referral Code

To get referral code, please call the following function

String referralCode = await FlyyFlutterPlugin.getFlyyReferralCode();

To Verify valid Referral Code

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

Map<String, dynamic> mapResult =
   await FlyyFlutterPlugin.verifyReferralCode("asdkjjkj23");

//To get result
print(mapResult["is_valid"]);
print(mapResult["referral_code"]);

To get share data

Use the below code to get share data. In the callback you will receive following params

  1. referral_link - Referral link to share as string
  2. referral_message - Referral message to share as string
  3. Share_message - Share message as string
try {
 Map<String, dynamic> mapShareData =
     await FlyyFlutterPlugin.getShareData();

 //To get result
 print(mapShareData["referral_link"]);
 print(mapShareData["referral_message"]);
 print(mapShareData["share_message"]);
} on PlatformException catch (e) {
 print(e.message);
}

To get referral count

Use the below code to get referral count. In the callback you will receive referral count as integer.

try {
 int referralCount = await FlyyFlutterPlugin.getReferralCount();

 //To get result
 print(referralCount);
} on PlatformException catch (e) {
 print(e.message);
}

To get scratch card count

Use the below code to get scratch card count.

try {
 Map<String, dynamic> mapShareData =
     await FlyyFlutterPlugin.getScratchCardCount();

 //To get result
 print(mapShareData["total_sc_count"]);
 print(mapShareData["scratched_sc_count"]);
 print(mapShareData["unscratched_sc_count"]);
 print(mapShareData["locked_sc_count"]);
} on PlatformException catch (e) {
 print(e.message);
}

To get previous leaderboard winner

Use the below code to get previous leaderboard winners.

try {
 Map<String, dynamic> mapShareData =
     await FlyyFlutterPlugin.getPreviousLeaderboardWinners("<tag>");
 
 //To get result
 print(mapShareData["participants_count"]);
 print(mapShareData["winners"]);
 print(mapShareData["previous_winners"]);
} on PlatformException catch (e) {
 print(e.message);
}

To get leaderboard participants

Use the below code to get leaderboard participants.

try {
 Map<String, dynamic> mapShareData =
     await FlyyFlutterPlugin.getLeaderboardParticipants("<tag>");
 
 //To get result
 print(mapShareData["participants_count"]);
 print(mapShareData["winners"]);
 print(mapShareData["previous_winners"]);
} on PlatformException catch (e) {
 print(e.message);
}

To get wallet balance

Use the below code to get wallet balance.

try {
 Map<String, dynamic> mapShareData =
     await FlyyFlutterPlugin.getWalletBalance("cash");
 
 //To get result
 print(mapShareData["balance"]);
 print(mapShareData["total_credit"]);
 print(mapShareData["total_debit"]);
} on PlatformException catch (e) {
 print(e.message);
}

To get referrer details

Use the below code to get referrer details.

try {
 Map<String, dynamic> mapShareData1 =
     await FlyyFlutterPlugin.getReferrerDetails();
 
 //To get result
 print(mapShareData1["name"]);
 print(mapShareData1["ext_uid"]);
 print(mapShareData1["extra_data"]);
} on PlatformException catch (e) {
 print(e.message);
}

To get offers count

Use the below code to get offers count.

try {
 Map<String, dynamic> mapShareData2 =
     await FlyyFlutterPlugin.getOffersCount();
 
 //To get result
 print(mapShareData2["live_offers_count"]);
 print(mapShareData2["participated_offers_count"]);
} on PlatformException catch (e) {
 print(e.message);
}