Git Product home page Git Product logo

leads-sdk's Introduction

leads-sdk

Version License Platform

The Leads SDK provides an embeddable button for iOS apps to make lead capture from native apps incredibly easy. Leads are stored in the Salesforce Sales Cloud for sales teams to quickly action and drive further sales from any mobile application.

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

leads-sdk is available through CocoaPods. To install it, simply add the following line to your Podfile:

use_frameworks!

pod "leads-sdk"

or, to fetch the latest

use_frameworks!

pod 'leads-sdk' :git => 'https://github.com/quintonwall/leads-sdk.git'

Add the LeadsButton to a UIView

Within your storyboard, drag a standard button from the palette, then change its type to lead button

Then, in the properties editor, add the Salesforce org id provided by your Salesforce administrator. The return url is not really used in mobile apps. You can leave it set to the default. The pod currently does not use it, but future releases may support a webview sort of confirmation.

Pass lead information to LeadsButton

To add fields to the LeadsButton, create an outlet to your ViewController, and import the leads_sdk module.

import leads_sdk

class ViewController: UIViewController {

    @IBOutlet weak var myLeadButton: LeadsButton!

Add Standard Fields

LeadsButton is preconfigured to support the typical standard lead fields (fist name, last name, email, company, city, and state). When using standard fields, Salesforce administrators do no need to create a custom web-to-lead field. As long as web-to-lead is enabled in the Salesforce org, that is all you need.

  var d :Dictionary = [String: String]()

  //populate the standard fields
  d[Leads.StandardFields.FIRST_NAME] = "Quinton"
  d[Leads.StandardFields.LAST_NAME] = "Wall"
  d[Leads.StandardFields.EMAIL] = "[email protected]"
  d[Leads.StandardFields.COMPANY] = "Salesforce"
  d[Leads.StandardFields.CITY] = "San Francisco"
  d[Leads.StandardFields.STATE] = "CA"

Add Custom Fields

Salesforce Leads also support custom fields. Your administrator will need to use the web-to-lead feature within Salesforce to generate the unique custom field Ids. If you are only collecting standard lead fields, there is no need to generate a web-to-lead form. Once you have these field ids, simply add them to the dictionary object.

  //populate custom fields
  d["00NG000000CZxsC"] = "MyCustomValue"

Send the Leads to Salesforce

Once you have your fields Dictionary create, add the dictionary to the LeadsButton and call sendLead(). SendLead also checks to ensure that you have specified an Org Id throwing an error if it is not set correctly.

  myLeadButton.formFields = d
  do {
         try myLeadButton.sendLead()
    }
    catch Leads.LeadError.NoOrgId {
        print("no org id set!")
    }
    catch Leads.LeadError.CommsFailure {
        //comms problem
    }
    catch {
        //unexpected error
    }

Adding Themes

Three UI themes have been included in LeadsButton:

  1. Default: Default
  2. Dark: Dark
  3. Graphical Graphical

You can add a theme with the following command. If you do not specify any theme, you can set colors and styles manually.

  LeadsThemeManager.applyTheme(LeadsTheme.[Default | Dark | Graphical], leadsbutton: myLeadButton)

Sample Application

For a complete example of using the LeadsButton, please check out the sample app included in this project.

Author

Quinton Wall, @quintonwall

License

leads-sdk is available under the MIT license. See the LICENSE file for more info.

leads-sdk's People

Contributors

quintonwall avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.