Latest 0.2.0
License MIT
Platforms ios 10.0


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.


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



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


pod "leads-sdk"

or, to fetch the latest


pod '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.


Quinton Wall, @quintonwall


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

Latest podspec

    "name": "leads-sdk",
    "version": "0.2.0",
    "summary": "Collect leads in Salesforce Sales Cloud from any native iOS apps.",
    "description": "An easy to use embeddable button to let you collect leads in Salesforce from any native iOS app.",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "Quinton Wall": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.2.0"
    "social_media_url": "",
    "platforms": {
        "ios": "10.0"
    "requires_arc": false,
    "source_files": "Pod/Classes/**/*",
    "resource_bundles": {
        "leads-sdk": [
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This