iOS Swift
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.
SDK Initialization
Initialize pod in your AppDelegate or main entry point of the app.
//For Production
Flyy.sharedInstance.initSDK(partnerToken: "<partner_id>", environment: Flyy.FLYY_ENVIRONMENT_PRODUCTION)
//For Stage
Flyy.sharedInstance.initSDK(partnerToken: "<partner_id>", environment: Flyy.FLYY_ENVIRONMENT_STAGING)
Get Partner Id
You can find the partner ID in Flyy Dashboard.
Go to Settings -> SDK Keys

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

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.sharedInstance.setPackage("<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.sharedInstance.setThemeColor(colorPrimary: "#FF5733", colorPrimaryDark: "#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
Flyy.sharedInstance.setUser(externalUserId: "<user_id>")
//For SET NEW USER
//set new user id
Flyy.sharedInstance.setNewUser(externalUserId: "<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.sharedInstance.setUserName(userName: "<user_name>")
Offers Screen
To open offers a screen for users with or without segment id.
Flyy.sharedInstance.openOffersPage()
OR
Flyy.sharedInstance.openOffersPage(segmentId: segmentId)
Rewards Screen
To open rewards screen for user
Flyy.sharedInstance.openRewardsPage()
Wallet Screen
To open wallet screen for user
Flyy.sharedInstance.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.sharedInstance.sendFcmTokenToServer(fcmToken: fcmToken)
Handle Flyy Background Notification
Add the following line of code to allow us to handle flyy notifications when your app is in the background.
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)
{
let userInfo = response.notification.request.content.userInfo
if let notificationSource = userInfo["notification_source"]
{
if notificationSource as! String == "flyy_sdk"
{
Flyy.sharedInstance.handleBackgroundNotification(userInfo: 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.
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)
{
let userInfo = notification.request.content.userInfo
Messaging.messaging().appDidReceiveMessage(userInfo)
if let notificationSource = userInfo["notification_source"]
{
if notificationSource as! String == "flyy_sdk"
{
Flyy.sharedInstance.handleForegroundNotification(userInfo: userInfo)
}
}
completionHandler([[.alert, .sound]])
}
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.sharedInstance.setUserToken(userToken:”<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
Flyy.sharedInstance.setUserToken(userToken:”<user_token>”, segmentId:“<segment_id>”)
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.sharedInstance.setNewUserToken(userToken:”<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
Flyy.sharedInstance.setNewUserToken(userToken:”<user_token>”, segmentId:“<segment_id>”)
Set Bank Details
You can use the following method to set user redemption details, which takes following params,
- Account number - bank account number
- IFSC code
- Name
Flyy.sharedInstance.setBankDetails(accountNumber: “”, ifscCode: “”, accountHolderName: “”)
Set UPI Details
You can use the following method to set user redemption details, which takes following params,
- UPI ID
Flyy.sharedInstance.setUPI(accountNumber: “”, ifscCode: “”, accountHolderName: “”)
Set Referral Code
To set referral code, please call the following function
Flyy.sharedInstance.setReferralCode(referralCode: "tuwfj42")
Get Referral Code
To get referral code, please call the following function
let referralCode = Flyy.sharedInstance.getReferralCode()
Verify valid Referral Code
To verify if referral code is valid or not, please call the following function
Flyy.sharedInstance.verifyReferralCode(referralCode: "tuwfj42", onComplete: { (success, referralCode) -> Void in
if(success) {
print(referralCode)
}
})
To get share data
Use the below code to get share data
Flyy.sharedInstance.getShareData(onComplete: { (success, referralDetails) -> Void in
if(success) {
referralDetails[0] //to get referral link
referralDetails[1] //to get referral message
referralDetails[2] //to get share message
}
})
To get referral count
Use the below code to get referral count.
Flyy.sharedInstance.getReferralCount(onComplete: {(success, referralCount) -> Void in
if(success) {
referralCount //referral_count
}
})
To get scratch card count
Use the below code to get scratch card count.
Flyy.sharedInstance.getScratchCardCount(onComplete: {
(success, scratchCardCountData) -> Void in
if(success) {
print("Total SC Count \(scratchCardCountData[0])")
print("Scratched SC Count \(scratchCardCountData[1])")
print("UnScratched SC Count \(scratchCardCountData[2])")
print("Locked SC Count \(scratchCardCountData[3])")
}
})
To get previous leaderboard winner
Use the below code to get previous leaderboard winners.
Flyy.sharedInstance.getPreviousLeaderboardWinners(tag: "test", onComplete: {
(success, message, participantsCount, winnersArray, previousWinnersArray) -> Void in
if(success) {
print("Message \(message)")
print("Participants Count \(participantsCount)")
print(winnersArray)
print(previousWinnersArray)
let data = winnersArray.data(using: .utf8)!
do {
if let jsonArray = try JSONSerialization.jsonObject(with: data, options : .allowFragments) as? [Dictionary<String,Any>]
{
print(jsonArray)
print(jsonArray[0]["rank"])
} else {
print("bad json")
}
} catch let error as NSError {
print(error)
}
} else {
print(message)
}
})
To get leaderboard participants
Use the below code to get leaderboard participants.
Flyy.sharedInstance.getLeaderboardParticipants(tag: "test", onComplete: {
(success, message, participantsCount, winnersArray, previousWinnersArray) -> Void in
if(success) {
print("Message \(message)")
print("Participants Count \(participantsCount)")
print(winnersArray)
print(previousWinnersArray)
let data = winnersArray.data(using: .utf8)!
do {
if let jsonArray = try JSONSerialization.jsonObject(with: data, options : .allowFragments) as? [Dictionary<String,Any>]
{
print(jsonArray)
print(jsonArray[0]["rank"])
} else {
print("bad json")
}
} catch let error as NSError {
print(error)
}
} else {
print(message)
}
})
To get wallet balance
Use the below code to get wallet balance.
Flyy.sharedInstance.getWalletBalance(walletLabel: "points", onComplete: {
(success, walletBalanceData) -> Void in
if(success) {
print("Balance \(walletBalanceData[0])")
print("Total Credit \(walletBalanceData[1])")
print("Total Debit \(walletBalanceData[2])")
}
})
To get referrer details
Use the below code to get referrer details.
Flyy.sharedInstance.getReferrerDetails(onComplete: {
(success, referralData) -> Void in
if(success) {
print("Name \(referralData[0])")
print("Ext UID \(referralData[1])")
print("Extra Data \(referralData[2])")
}
})
To get offers count
Use the below code to get offers count.
Flyy.sharedInstance.getOffersCount(onComplete: {
(success, offersCountData) -> Void in
if(success) {
print("Live offers Count \(offersCountData[0])")
print("Participated Offers Count \(offersCountData[1])")
}
})
Advanced Implementation
Set SDK Closed Listener
To set flyy sdk closed listener
Flyy.sharedInstance.setSDKClosedListener(flyysdkclosedlistener: self)
Listen to SDK Closed Listener
extension ViewController:FlyySDKClosedListener
{
func onSDKClosed(screenName: String)
{
print(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.sharedInstance.addUserToSegment(segmentTitle: "segment_title", segmentKey: "segment_key", onComplete: {
(success) -> Void in
if(success) {}
})
Updated about 3 years ago