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.
- Install XCode.
- Clone the Bolt iOS SDK Repo:
git clone https://github.com/BoltApp/bolt-ios-sdk.git
- In your terminal, navigate to
cd bolt-ios-sdk
and runopen YourShopApp.xcworkspace
. - Choose
CheckoutExample
as the target in XCode and run it.
Step 1: Install Bolt’s iOS SDK Package
-
Install CocoaPods.
-
Install the Bolt iOS SDK Library:
git clone https://github.com/BoltApp/bolt-ios-sdk.git
-
Add a new source in your Podfile:
source 'https://github.com/BoltApp/podspecs.git'
-
Add a new target:
pod 'BoltCheckout'
-
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
-
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.
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.