CocoaPods trunk is moving to be read-only. Read more on the blog, there are 17 months to go.

GramercySDK 1.0.15

GramercySDK 1.0.15

TestsTested
LangLanguage Obj-CObjective C
License Custom
ReleasedLast Release Nov 2017
SwiftSwift Version 3.2

Maintained by Gramercy.



 
Depends on:
FBSDKCoreKit= 4.26
FBSDKShareKit= 4.26
FBSDKMessengerShareKit= 1.3.2
Branch= 0.18.8
Alamofire= 4.5
Kingfisher= 4.3.1
Locksmith= 3.0.0
SwiftyJSON= 4.0.0-alpha.1
ReachabilitySwift= 3
SwiftHEXColors= 1.1.0
 

GramercySDK

Installation

Cocoapods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

	$ gem install cocoapods

To integrate GramercySDK into your Xcode project using Cocoapods, specify it to a target in your Podfile:

	platform :ios, '9.0'

	target 'testapp' do
	  use_frameworks!
  	pod 'GramercySDK', '1.0.15'
	end

Then, run the following command:

	$ pod install

You should then open the {Project}.xcworkspace instead of the {Project}.xcodeproj after you installed anything from CocoaPods.

Configuration

  1. Create a new Facebook App ID here: https://developers.facebook.com/
  2. In Xcode, secondary-click your project's .plist file and select Open As -> Source Code.
  3. Insert the following XML snippet into the body of your file just before the final </dict> element.
<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb{{ YOUR FACEBOOK APP ID }}</string>
            </array>
        </dict>
    </array>
    <key>FacebookAppID</key>
    <string>{{ YOUR FACEBOOK APP ID }}</string>
    <key>FacebookDisplayName</key>
    <string>{{ YOUR APP NAME }}</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fb-messenger</string>
        <string>whatsapp</string>
        <string>fbapi</string>
        <string>fb-messenger-api</string>
        <string>fbauth2</string>
        <string>fbshareextension</string>
    </array>

NOTE: make sure to include your facebook app id in the .plist!

Usage

basics

Import the SDK with

Swift

import GramercySDK

Objective-C

@import GramercySDK;

Tracking application installs

After importing, include this in your AppDelegate.swift

Swift:

    let gramercyCampaign:String = "YOUR_CAMPAIGN_ID"
    let gramercyKey:String = "YOUR_API_KEY"


    func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

        Gramercy.start(withLaunchOptions: launchOptions,
                       key: gramercyKey,
                       campaign: gramercyCampaign) { (success, error) in
          // do something after a user is attributed a referral
        }

        return true
    }

Objective-C

    NSString *key = @"YOUR_CAMPAIGN_ID";
    NSString *campaign = @"YOUR_API_KEY";

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    [Gramercy startWithLaunchOptions:launchOptions
                                 key:key
                            campaign:campaign
                            callback:^(BOOL success, NSError * _Nullable error) {
                                // do something after a user is attributed a referral
                            }];

    return YES;
}

Identifying users

After initializing and starting the SDK, you can identify your users for referral attribution. Our recommendation for when and how often you should call identify is as follows:

  • After a user registers (required)
  • After a user logs in (required)
  • When a user updates their info (e.g. updates email address — optional)
  • Upon loading any pages that are accessible by a logged in user (optional)

Swift

  let visitor: GRVisitor = GRVisitor(id:"REFERRED_USER_ID")
  visitor.email = "[email protected]"
  visitor.firstName = "John"
  visitor.lastName = "Doe"
  visitor.phone = "17778889999"

  Gramercy.identifyVisitor(visitor:visitor) { (success, error) in
    // do something after the user is identified
  }

Summoning the referral modal

After identifying your users, you can instantiate and present the referral view controller from any other view controller

Swift

Gramercy.presentReferralsViewController()

// Or alternatively

let controller = Gramercy.instantiateReferralsViewController()
self.present(controller!, animated: true, completion: nil)

Objective-C

[Gramercy presentReferralsViewController];

Or alternatively

ReferralsViewController *viewController = [Gramercy instantiateReferralsViewController];
[self showViewController:viewController sender:self];