📍 Bolt Help / Developer Resources / SDKs / iOS WebView SDK Setup
iOS WebView SDK Setup
Install Bolt into your iOS tech stack using our platform software development kits (SDKs).

Welcome to the Bolt iOS SDK! Our goal is to deliver the most innovative checkout experience possible — for both you and your shoppers. To get started, follow this guide to install the iOS SDK on your application.

Explore the Bolt iOS SDK

INFO

This is an optional step and is not required for installing the Bolt iOS SDK.

  1. Install XCode.
  2. Clone the Bolt iOS SDK Repo: git clone https://github.com/BoltApp/bolt-ios-sdk.git
  3. In your terminal, navigate to cd bolt-ios-sdk and run open YourShopApp.xcworkspace.
  4. Choose CheckoutExample as the target in XCode and run it.

Step 1: Install Bolt’s iOS SDK Package

  1. Install CocoaPods.

  2. Install the Bolt iOS SDK Library:

    git clone https://github.com/BoltApp/bolt-ios-sdk.git
    
  3. Add a new source in your Podfile:

    source 'https://github.com/BoltApp/podspecs.git'
    
  4. Add a new target:

    pod 'BoltCheckout'
    
  5. Your podfile should then look something like this:

    source 'https://github.com/BoltApp/podspecs.git'
    target 'YourShopApp' do
    // Comment out the next line if you don't want to use dynamic frameworks.
    Use_frameworks!
    pod 'BoltCheckout'
    end
    
  6. Finally, install your Podfile again via your commandline to set the SDK as a dependency in your project:

    pod install
    

Step 2: Initialize the Bolt SDK

Before SDK functionality can be called anywhere in your code, you must initialize the SDK.

Create a BoltCheckout object and store it as an instance variable. Keys and IDs can be found in Merchant Dashboard > Developers > API.

let checkout = BoltCheckout(
    publishableKey: "INSERT_YOUR_PUBLISHABLE_KEY",
    apiKey: "INSERT_YOUR_API_KEY",
    merchantDivisionId: "INSERT_YOUR_DIVISION_ID",
    environment: .production // Replace with appropriate environment
)

Step 3: Generate an Order Token

Wherever you want to start checkout, you first need to create an order token to generate the Webview URL.

Your storefront app will need to tokenize the basket data and retrieve an order token via an order request with the createOrderToken endpoint. Similarly, a Progressive Web App (PWA) requires the token to initialize and configure the Bolt Checkout Button.

graph LR A[Bolt] <--> B((Bolt API)) B <--> D([Android App]) B <--> E([iOS App]) B <--> F([PWA]) D -->|token| G[Webview Checkout] E -->|token| H[Webview] F -->|token| I[iFrame Checkout]

The order token will be returned as a string in a successful request with the value token, which you can then use to proceed with initializing checkout.

{
  "cart": { ... },
  "dynamic_content": { ... },
  "external_data": { ... },
  "token": "string",
  "user_note": "string"
}

Step 4: Start Checkout

After you have received the order token, call the startCheckout method on the instance of BoltCheckout

Step 5: Receive Callback Events

When checkout is complete, pass in an instance of BoltCheckoutDelegate to receive callback events.

// ExampleViewController.swift
extension ExampleViewController: BoltCheckoutDelegate {

    func handleCheckoutStart(orderToken: String) {
        checkout.startCheckout(
            presentingViewController: self,
            orderToken: orderToken,
            delegate: self
        )
    }

    func checkoutDidComplete(orderReference: String) { ... }
    func checkoutDidFail(at step: BoltCheckoutStep, error: Error) { ... }
    func checkoutDidCancel(at step: BoltCheckoutStep) { ... }
}

Next

After you’ve set up and configured iOS Webview, you can set up a custom Checkout Exit experience or customize your Bolt Checkout Button.

Filter by Section
Filter by Topic