-
Add the following repository URL:
https://github.com/Imprint-Tech/imprint-sdk-ios -
Select your desired version or branch
-
Click Add Package
You can also add Imprint as a dependency to your Package.swift:
dependencies: [
.package(url: "https://github.com/Imprint-Tech/imprint-sdk-ios", from: "0.1.6")
]Add Imprint iOS SDK to your project using CocoaPods(minimum support cocoapods version: 1.16.1):
-
If you haven't already, install CocoaPods:
sudo gem install cocoapods
-
Create a Podfile in your project directory if you don't have one:
pod init
-
Add Imprint iOS SDK to your Podfile:
target 'YourApp' do pod 'Imprint' end
-
Install the dependencies:
pod install
-
Open the
.xcworkspacefile that CocoaPods created (not the.xcodeproj).
-
Import the SDK
import Imprint -
Configuration Create an instance of
ImprintConfigurationwith yourclient_secretandenvironment, then assign additional optional fields as needed.let configuration = ImprintConfiguration(clientSecret: "client_secret", environment: .sandbox)
-
Define the Completion Handler Define the completion handler onCompletion to manage the terminal states when the application flow ends.
configuration.onCompletion = { state, data in switch state { case .offerAccepted: self.completionState.text = "Offer accepted\n\(self.jsonString(data))" case .rejected: self.completionState.text = "Application rejected\n\(self.jsonString(data))" case .inProgress: self.completionState.text = "Application Interrupted - In Progress" case .error: self.completionState.text = "Error occured\n\(self.jsonString(data))" @unknown default: break } }
-
Start the Application flow Once you’ve configured the ImprintConfiguration, initiate the application flow by calling ImprintApp.startApplication from your view controller.
public static func startApplication(from viewController: UIViewController, configuration: ImprintConfiguration)
viewController: The view controller from which the application flow will be presented
configuration: The previously created ImprintConfiguration object containing your API key and completion handler
