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

iOS Objective C

Version:- 1.3.16

Add Dependency

Step 1: Podfile

To install flyy pod, simply add the following line to your Podfile.

pod 'FlyyFramework', '1.3.16'

Step 2: Pod Install

Run pod install command in your project root terminal. If the required pod version is not getting downloaded, run pod update/pod repo update and pod install.

Here ends adding dependency related to FlyyFramework pod, clean and build your app before further integration.

Declare Flyy variable

Declare flyy variable to use in the class.

@interface YourViewController ()<>
{
    Flyy *flyy;
}

Initialize Flyy variable

flyy = [Flyy sharedFlyyInstance];

SDK Initialization

Initialize pod in your AppDelegate or main entry point of the app.

//For Production
[flyy initSDKWithPartnerToken:@"<partner_id>" environment: [flyy production]];


//For Stage
[flyy initSDKWithPartnerToken:@"<partner_id>" environment: [flyy stage]];

Get Partner Id

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

1752

Register Package Name

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

1500

Set Package Name

Please note for Flyy Pod to work, setting the package name is very important.

Package name should be the same as your package name given in the Flyy Dashboard while doing Connect SDK. Please make sure the package name provided should not mismatch.

You can set your package name using the following method.

[flyy setPackageWithPackageName:@"<package_name_same_as_registered_in_flyy_dashboard>

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 color_primary and color_primary_dark
[flyy setThemeColorWithColorPrimary:@"" colorPrimaryDark:@""];

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
[flyy setUserWithExternalUserId: @"<user_id>"];
//For SET NEW USER

//set new user id
[flyy setNewUserWithExternalUserId: @"<user_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

[flyy setUserNameWithUserName: @"<user_name>"];

Offers Screen

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

[flyy openOffersPage];
                OR
[flyy openOffersPageWithSegmentId:@""];

Rewards Screen

To open rewards screen for user

[flyy openRewardsPage];

Wallet Screen

To open wallet screen for user

[flyy openWalletPage];

Send FCM Token

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.

[flyy sendFcmTokenToServerWithFcmToken:@"<fcm_token>"];

Handle Flyy Background Notification

Add the following line of code to allow us to handle flyy notifications when your app is in the background.

- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
         withCompletionHandler:(void(^)(void))completionHandler
{
    NSDictionary *userInfo = response.notification.request.content.userInfo;
    NSLog(@"%@", userInfo);
    NSString *notificationSource = [userInfo valueForKey:@"notification_source"];
    if (notificationSource != nil && [notificationSource isEqualToString:@"flyy_sdk"])
    {
        flyy = [Flyy sharedFlyyInstance];
        [flyy handleBackgroundNotificationWithUserInfo:userInfo];
    }
    completionHandler();
}

Handle Flyy Foreground Notification

Add the following line of code to allow us to handle flyy notifications when your app is in the foreground.

- (void)userNotificationCenter:(UNUserNotificationCenter *)center
    willPresentNotification:(UNNotification *)notification
     withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
{
  NSDictionary *userInfo = notification.request.content.userInfo;


  [[FIRMessaging messaging] appDidReceiveMessage:userInfo];
  
  NSString *notificationSource = [userInfo valueForKey:@"notification_source"];
  if (notificationSource != nil && [notificationSource isEqualToString:@"flyy_sdk"])
  {
    flyy = [Flyy sharedFlyyInstance];
    [flyy handleForegroundNotificationWithUserInfo:userInfo];
  }
 completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionAlert);
}

Additional Methods

Set User Token

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

[flyy setUserTokenWithUserToken:@""];

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

[flyy setUserTokenWithUserToken:@"" segmentId:@""];

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

[flyy setNewUserTokenWithUserToken:@""];

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

[flyy setNewUserTokenWithUserToken:@"" segmentId:@""];

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
[flyy setBankDetailsWithAccountNumber:@"" ifscCode:@"" accountHolderName:@""];

Set UPI Details

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

  1. UPI ID
[flyy setUPIWithUpiId:@""];

Set Referral Code

To set referral code, please call the following function

[flyy setReferralCodeWithReferralCode:@""];

Get Referral Code

To get referral code, please call the following function

NSString *referralCode = [flyy getReferralCode];

Verify valid Referral Code

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

[flyy verifyReferralCodeWithReferralCode:@"" onComplete:^(BOOL isValid, NSString* referralUrl) {}];

To get share data

Use the below code to get share data

[flyy getShareDataOnComplete: ^(BOOL success, NSArray<NSString *> *referralDetails) {
        NSLog(@"%@", referralDetails[0]); //referral link
        NSLog(@"%@", referralDetails[1]); //referral message
        NSLog(@"%@", referralDetails[2]); //share message
    }];

To get referral count

Use the below code to get referral count.

[flyy getReferralCountOnComplete:^(BOOL success, NSInteger referralCount) {
        NSLog(@"%ld", (long)referralCount);
}];

To get scratch card count

Use the below code to get scratch card count.

[flyy getScratchCardCountOnComplete: ^(BOOL success, NSArray<NSNumber *> *scratchCardCountData) {
        NSLog(@"%@", scratchCardCountData[0]); //total sc count
        NSLog(@"%@", scratchCardCountData[1]); //scratched sc count
        NSLog(@"%@", scratchCardCountData[2]); //unscrached sc count
        NSLog(@"%@", scratchCardCountData[3]); //locled sc count
    }];

To get previous leaderboard winner

Use the below code to get previous leaderboard winners.

[flyy getPreviousLeaderboardWinnersWithTag:@"test" onComplete:^(BOOL success, NSString* message, NSInteger participantsCount, NSString* winners, NSString* previousWinners) {}];

To get leaderboard participants

Use the below code to get leaderboard participants.

[flyy getLeaderboardParticipantsWithTag:@"test" onComplete:^(BOOL success, NSString* message, NSInteger participantsCount, NSString* winners, NSString* previousWinners) {}];

To get wallet balance

Use the below code to get wallet balance.

[flyy getWalletBalanceWithWalletLabel:@"cash" onComplete:^(BOOL success, NSArray<NSNumber *> *walletBalance) {
        NSLog(@"%@", walletBalance[0]); //balance
        NSLog(@"%@", walletBalance[1]); //total credit
        NSLog(@"%@", walletBalance[2]); //total debit
    }];

To get referrer details

Use the below code to get referrer details.

[flyy getReferrerDetailsOnComplete:^(BOOL success, NSArray<NSString *> *referrerDetailsData) {
        NSLog(@"%@", referrerDetailsData[0]); //name
        NSLog(@"%@", referrerDetailsData[1]); //ext uid
        NSLog(@"%@", referrerDetailsData[2]); //extra data
    }];

To get offers count

Use the below code to get offers count.

[flyy getOffersCountOnComplete: ^(BOOL success, NSArray<NSNumber *> *offersCount) {
        NSLog(@"%@", offersCount[0]); //live offers count
        NSLog(@"%@", offersCount[1]); //participated offers count
    }];

Advanced Implementation

Set SDK Closed Listener

To set flyy sdk closed listener

[flyy setSDKClosedListenerWithFlyysdkclosedlistener:self];

Listen to SDK Closed Listener

@interface ViewController ()<FlyySDKClosedListener> {}

Protocol Callback Method When SDK is Closed

- (void)onSDKClosedWithScreenName:(NSString * _Nonnull)screenName {
    NSLog(@"Flyy %@",screenName);
}

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

[flyy addUserToSegmentWithSegmentTitle:segmentTitle segmentKey:segmentKey onComplete: ^(BOOL success) {}];