Favcy iOS SDK (v1.9): Developer Guide
The objective of this developer guide is to help iOS Developers to integrate with the Favcy Ecosystem, using the Favcy iOS SDK.
It is assumed, that the audience of this document has a good understanding of the iOS Development Environment. All the examples in this document are explained using Xcode as the IDE. The developers are required to use Xcode as the development IDE.
The tools required to access iOS Favcy SDK are Xcode and Facebook SDK. Since most applications are already using their own version of the Facebook SDK it is therefore not integrated as a part of the Favcy SDK.
The Favcy SDK is tested against Facebook SDK 4.11.0 and should stay compatible with the later versions as well.
Step 1.
Step 2.
Step 3.
Step 4.
Add the path of the Facebook SDK(where Facebook SDK is downloaded) here in both of these subcategories. Remember, the Facebook SDK must neither be placed in the project folder nor it must be added in the project(By Adding files or drag and drop). The other general settings to attach Facebook SDK are to be done as defined by Facebook. Step 5.
|
In order to use the Favcy SDK, the following Helper Classes need to be understood.
The object of this class is returned with the Error Message and Error Code.
This class is the storage class for all the parameters, that are required by the application. The FavcyProfile will be returned with the associated parameters on successful user logIn.
The various methods to fetch profile information from FavcyProfile are
Returns the Email ID of the User.
Returns the Total Points the user has corresponding to thebrand.
Returns the group name the user is a part of.
Returns the URL for the brand image, as configured in the Favcy Eco System
Returns the user token associated with Favcy and is specific to the group the user is part of.
Returns the Social ID for the user. Currently the Android SDK only supports Facebook Logins.
Returns the first name of the user as received from the Login Server (Facebook/Twitte
Returns the last name of the user as received from the Login Server (Facebook/Twitter).
Returns the name of the currency as received.
Returns the URL of the Profile Picture of the User.
Returns the gender of the logged in user
Returns the last name of the user as received from the Login Server (Facebook/Twitter).
This class is the storage class for all the parameters, that are required by the application. The FavcyShop object will be returned with the associated parameters on calling getOffers() API successfully.
Get the URL associated with this shop. The URL can be used to open the shop in a Web view. In order for the user to stay signed in to Favcy, you need to pass the FavcyApp ID and Favcy User Token with the URL.
NSString *favcyShopUrl = [favcyShop getShopURL]; favcyShopUrl = [NSString stringWithFormat:@"%@?app_id=%@&usertoken=%@",favcyShopUrl,favcyapp_id,favcyusertoken]; |
This returns the name of the Shop.
Returns a string containing the URL of the Shop Icon
This represents the Shop ID as configured in the Favcy Backend. Currently there is no use of this API, but is to be used for future purpose (to support in-App Shops)
The function returns a small description, associated with the shop
The function returns the support email, as configured on the backend for this shop.
This represents the mobile number associated with the shop.
Returns the URL for the FAQ page. When opening the URL, please pass the application ID and user token
NSString *favcyFaqUrl = [favcyShop getShopFaqUrl]; favcyFaqUrl = [NSString stringWithFormat:@"%@?app_id=%@&usertoken=%@",favcyFaqUrl,favcyapp_id,favcyusertoken]; |
This class is the storage class for all the parameters, that are required by the application. will be returned with the associated parameters on calling getActions() API successfully.
The various methods to fetch profile information from FavcyAction are
-(NSString *)getCode;
Get the code associated with action to be used in the PassPoint API.
-(NSString *)getDescription;
This is the description of the Action, to be used for display purpose
-(NSString *)getPoints;
Returns point corresponding to the action, that the user earns on the action.
Class Favcy.h
The Favcy class is a singleton class, providing the context to the Favcy SDK.
The class method is:
This method returns the instance of the class.
Usage Example: Objective-c: Favcy *favcy = [Favcy getInstance]; Swift: let favcy = Favcy.getInstance() |
The public methods are:
This should be the first function to be called, using the instance of the “Favcy.h”. This function initializes the SDK.
Usage Example: Objective-c: [favcy init:@"APP_ID" completionHandler:^(id result, id error) { if(error) { // Handle Error here... } else { // Handle result/success here... } }]; |
‘APP_ID’ is a unique application- id for your application.
The function is used to Login the user into Favcy.
Usage Example: Objective-c: Favcy *favcy = [Favcy getInstance]; [favcy login:self completionHandler:^(id result, id error) { if(error) { // Handle Error here... } else{ // Handle result/success here... } }]; |
‘self’ represents the UIViewController from where the function is being called.
The function is used to Logout the user from Favcy.
Usage Example: Objective-c: Favcy *favcy = [Favcy getInstance]; [favcy logout]; |
The function returns an object of the FavcyProfile, which provides data and methods to fetch user as well as brand information.
The function returns the appId stored with the SDK.
This function returns true, if the user is successfully logged in and false otherwise.
Please note, that this function should be called post calling the Init API to confirm, if the user is already logged in or not.
This function is used to provide a list of the different Favcy Shops that are available to the brand. Each Shop in the List provides the URL to the Shop, which can be opened in the WAP view. The URL also need to be appended with favcy user token and appID as parameters, for the user to stay logged in into Favcy.
Usage Example: Objective-c: Favcy *favcy = [Favcy getInstance]; [favcy getOfferShops:^(NSArray *result, id error) { if(error) { // Handle Error here... } else{ // Handle result/success here... } }]; |
This function is used to pass user brand points. The brand points are passed based on the action_codes (for both standard actions and the custom actions), as configured on the Admin Panel.
Please note the custom actions, when configured on the admin panel are approved by Favcy Administrators, before they can be used.
Usage Example: Objective-c: [favcy passPoints:@"Facebook_Liked" completionHandler:^(id result, id error) { if(error) { // Handle Error here... } else{ // Handle result/success here... } }]; |
Same as the previous function, except optionalParams. The optionalParams applies to some actions where the associated URL is passed. It is recommended that this method with associated URL (or some unique string) in the optionalParams is used.
Usage Example: Objective-c: [favcy passPoints:@"Facebook_Liked" optionalParam:@"optional" completionHandler:^(id result, id error) { if(error) { // Handle Error here... } else{ // Handle result/success here... } }]; |
This function is used to provide a referral link for the user. The same can be used to forward via, whatsapp, SMS or any other messaging API. The user gets refferal bonus points, every time a user joins the brand on Favcy using the referral link.
Usage Example: Objective-c: Favcy *favcy = [Favcy getInstance]; [favcy getReferralLink:^(id result, id error) { if(error) { // Handle Error here... } else{ // Handle result/success here... } }]; |
-(void)getActions:(void(^)(id result, id error))completionHandler
The function is used to get a list of Favcy actions that the application can use and the corresponding configuration on the Favcy Eco System. Please refer the FavcyAction class description for methods of the FavcyAction class.
Usage Example: Objective-c: Favcy *favcy = [Favcy getInstance]; [favcy getActions:^(id result, id error) { if(error) { // Handle Error here... } else{ // Handle result/success here... } }]; |
-(void)refreshProfile:(void(^)(id result, id error))completionHandler
This function is used to refresh the user profile.
-(void)refreshProfile { Favcy *favcy = [Favcy getInstance]; [favcy refreshProfile:^(id result, id error) { if(error) { // Handle Error here... } else{ // Handle result/success here... } }]; } |
Use Cases
In order to Login, please call the method Login of the class Favcy from within a controller.
PREREQUISITE: Init function must be called before calling this API.
/* Sample Code for Login on a button click */ -(IBAction)loginButtonTapped:(id)sender { [favcy login:self completionHandler:^(id result, id error) { if(error) { FavcyError *errorObject = error; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sorry!" message:errorObject.getErrorMessage delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show]; } else{ FavcyProfile *favcyProfile = result; self.lblUserName.text = favcyProfile.getFullName; NSURL *pictureURL = [NSURL URLWithString:favcyProfile.getPicture]; [self.profileImage setImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:pictureURL]]]; } }]; |
All Users on Sign up to a brand are credited 100 Brand Points, at the same time 100 Brand Points are credited to the Brand Float. The developer can identify activities for which the user can be given more brand points.
In order to pass points for an action, the PassPoints API need to be called
Below is the sample code for passing brand points to the user for standard action “Facebook_Share”.
-(IBAction)passCoinsButtonTapped:(id)sender { Favcy *favcy = [Favcy getInstance]; [favcy passPoints:@"Facebook_Liked" completionHandler:^(id result, id error) { if(error) { FavcyError *errorObject = error; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sorry!" message:errorObject.getErrorMessage delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show]; } else { NSString *points = result; NSLog(@"result Points %@", points); } }]; } |
The Users can avail the different offers that are available for a brand. In order to let users see and avail offers, the application needs to fetch a list of available offers shops. The API returns a list of offers shops along with their respective URLs. The application can open the URL in an in-App browser for the user to browse and avail offers.
The sample code for Fetching the OfferShops is :
-(IBAction)getOffersButtonTapped:(id)sender { Favcy *favcy = [Favcy getInstance]; [favcy getOfferShops:^(NSArray *result, id error) { if(error) { FavcyError *errorObject = error; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sorry!" message:errorObject.getErrorMessage delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show]; } else { NSArray *favcyShops = result; for (int i = 0; i < favcyShops.count; i++) { FavcyShop *favcyShop = [[FavcyShop alloc] init]; favcyShop = [favcyShops objectAtIndex:i];
NSLog(@"Shop Name %@", favcyShop.getShopName); } } }]; } |
-(IBAction)referralLinkButtonTapped:(id)sender { Favcy *favcy = [Favcy getInstance]; [favcy getReferralLink:^(id result, id error) { if(error) { FavcyError *errorObject = error; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sorry!" message:errorObject.getErrorMessage delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show]; } else { NSString *URL = result; NSLog(@"url %@",URL); } }]; } |
-(IBAction)getActionButtonTapped:(id)sender { Favcy *favcy = [Favcy getInstance]; [favcy getActions:^(id result, id error) { if(error) { FavcyError *errorObject = error; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sorry!" message:errorObject.getErrorMessage delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show]; } else{ NSArray *actionsArray = result; for (int i = 0; i < actionsArray.count; i++) { FavcyAction *favcyAction = [[FavcyAction alloc] init]; favcyAction = [actionsArray objectAtIndex:i];
NSLog(@"Name-- %@ and Points-- %@", favcyAction.getDescription,favcyAction.getPoints); } } }]; } |
IOS SDK Developer Guide (Confidential)
Revision: v0.1
Copyright © : Experience Global Mobile Technologies Pvt Ltd.