Skip to main content

Installation

Swift Package Manager
  1. Add the following repository URL
https://github.com/Imprint-Tech/imprint-sdk-ios
  1. Select your desired version or branch
  2. Click Add Package
Or you can also add Imprint as a dependency to your `Package.swift`:
dependencies: [
    .package(url: "https://github.com/Imprint-Tech/imprint-sdk-ios", from: "1.0.0")
]

Implementation

  1. Import the SDK
Import the SDK in your view controllers or wherever needed:
import Imprint
  1. Configuration
Create an instance of ImprintConfiguration with your client_secret and environment, then assign additional optional fields as needed.
let configuration = ImprintConfiguration(clientSecret: "client_secret", environment: .sandbox)
  1. 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:
    print("Offer accepted, data: \(String(describing: data))")
  case .rejected:
    print("Application rejected, data: \(String(describing: data))")
  case .inProgress:
    print("Incomplete application, data: \(String(describing: data))")
  case .error:
    print("Error occurred, data: \(String(describing: data))")
  }
  // Perform any generic actions after the flow ends if needed
}
  1. Start the Application flow
Once you’ve configured the ImprintConfiguration, initiate the application flow by calling 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

Complete Code Example

Check out our complete demo project at Imprint-Tech/imprint-sdk-ios
import Imprint

class YourViewController: UIViewController {

  // …
  
  func startImprintApplication() {
    let configuration = ImprintConfiguration(clientSecret: "client_secret", environment: .sandbox)
    
    // Define the completion handler
    configuration.onCompletion = { state, data in
      switch state {
      case .offerAccepted:
        print("Offer accepted, data: \(String(describing: data))")
      case .rejected:
        print("Application rejected, data: \(String(describing: data))")
      case .inProgress:
        print("Incomplete application, data: \(String(describing: data))")
      case .error:
        print("Error occurred, data: \(String(describing: data))")
      }
      // Perform any generic actions after the flow ends if needed
    }
    
    ImprintApp.startApplication(from: self, configuration: configuration)
  }
}
Request Parameters
PROPERTY NAMESREQUIREDTYPEDESCRIPTION
client_secretTRUEStringGenerated through Create Customer Session
offerConfigUUIDFALSEStringIdentifier for specific reward offer in the referral system
Response Data
PROPERTY NAMESTYPEDESCRIPTION
customer_idString | nullImprint identifier for customer
partner_customer_idString | nullPartner identifier for customer
payment_method_idString | nullID to the payment method of customer
error_codeErrorCode | nullIdentifier for the specific error encountered
ErrorCode (Enum)
ENUMDESCRIPTION
INVALID_CLIENT_SECRETIndicate Client Secret is invalid
UNKNOWN_ERRORIndicate other unexpected error happened
Application States
ENUMDESCRIPTION
offerAcceptedApplication has been approved and credit offer accepted. New cardholder!
rejectedApplication has been rejected by Imprint
inProgressApplication has been exited, not completed
errorInvalid request parameters (e.g., invalid token)