StreamPOS SDK
  • Introduction
  • Get Started
  • Security
  • SDK
  • Remote Integration
    • SDK Connect
    • iOS Integration
  • SDK Changelog
  • FAQ
  • SDK models
  • API endpoints
    • API
Powered by GitBook
On this page
  • Configuration
  • Functions
  • setupUI()
  • startPurchaseTransaction(amount: )
  • resetSetting()
  • $showUI
  • Example
  1. Remote Integration

iOS Integration

You can use StreamPay Connect in your IOS POS app

PreviousSDK ConnectNextSDK Changelog

Last updated 2 years ago

Configuration

  1. Download the framework from

  2. Import the framework into your projects

Steps:

  • In the project navigator, select your project.

  • Select your target.

  • Select the "General" tab.

  • Open "Framework, Libraries and Embedded Content" expander.

  • Click the + button.

  • Add file

  • (optional) or you can just drag and drop the file to "Framework, Libraries and Embedded Content".

3. Add Bluetooth as "Bluetooth Always Usage Description" to your info

4. import StreampayConnectKit

import StreampayConnectKit

5. Define connectivity object

@StateObject var conn: Connectivity = Connectivity.shared

6. add this modifier at the end of the root view

.streampayConnectivity()

7. Add sessionDelegate in the main root

.onAppear {
    conn.sessionDelegate = self
}

8. Start Purchase

conn.startPurchaseTransaction(amount: 300)

9. Add extension to root view

extension ContentView: TransactionSessionDelegate
{
    func transactionSesison(didReciviedDataFor transaction: StreampayConnectKit.RemoteTransaction?, withError error: Error?) {
        print("data received \(transaction)")
    }
    
    func transactionSession(didEndWithFor transaction: StreampayConnectKit.RemoteTransaction?, withError error: Error?) {
        print("data error \(error)")
    }
    
    
}

Functions

setupUI()

This function is used to show the setup UI of StreamPay connect

conn.setupUI()

startPurchaseTransaction(amount: )

Purchase is used to send the amount to the other Device

conn.startPurchaseTransaction(amount: 300)

resetSetting()

The reset setting is used to reset all the settings.

conn.resetSetting()

$showUI

ShowUI is a Boolean to check if UI is opened or closed.

var uiStatus = conn.showUI // it will be true or false

Example

Please check the example

import SwiftUI
import StreampayConnectKit

struct ContentView: View {
    
    @StateObject var connecetivity : Connectivity = .shared
    
    var body: some View {
        VStack(spacing: 30) {
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundColor(.accentColor)
                .onTapGesture {
                    connecetivity.startPurchaseTransaction(amount: 300)
                }
            Button("settings")
            {
                connecetivity.setupUI()
            }
            
            Text("Hello, world! \(Connectivity.name)")
        }
        .padding()
        .streampayConnectivity()
        .onAppear
        {
            connecetivity.sessionDelegate = self
        }
    }
}


extension ContentView: TransactionSessionDelegate
{
    public func transactionSesison(didReciviedDataFor transaction: StreampayConnectKit.RemoteTransaction?, withError error: Error?) {
        print("data received: \(transaction)")
    }
    
    public func transactionSession(didEndWithFor transaction: StreampayConnectKit.RemoteTransaction?, withError error: Error?) {
        print("error received: \(transaction)")
    }
    
    
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
import UIKit
import StreampayConnectKit

class ViewController: UIViewController {

    @IBOutlet weak var btnClickable: UIButton!
    var connectivity: Connectivity = Connectivity.shared
    override func viewDidLoad() {
        super.viewDidLoad()
        connectivity.sessionDelegate = self 
        connectivity.hostingUIViewController = self
    }


    @IBAction func onTap(_ sender: Any) {
       connectivity.setupUI()
        btnClickable.titleLabel?.text = " ali "
    }
    
    @IBAction func btnStartTransaction(_ sender: Any) {
        connectivity.startPurchaseTransaction(amount: 3922)
    }
    

    
}
extension ViewController: TransactionSessionDelegate {
    func transactionSesison(didReciviedDataFor transaction: StreampayConnectKit.RemoteTransaction?, withError error: Error?) {
        print("data received \(transaction)")
    }
    
    func transactionSession(didEndWithFor transaction: StreampayConnectKit.RemoteTransaction?, withError error: Error?) {
        print("err recived \(error)")
    }
    
    
}

Here