> For the complete documentation index, see [llms.txt](https://streampay.gitbook.io/streampos/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://streampay.gitbook.io/streampos/remote-integration/ios-integration.md).

# iOS Integration

## Configuration&#x20;

1. Download the framework from [Here](https://drive.google.com/file/d/1g0dLQzHfq9qs9jZ-6NwbNbNIz66C-3Iz/view?usp=share_link)
2. Import the framework into your projects

#### Steps:&#x20;

* 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&#x20;
* *(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

```java
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&#x20;

### setupUI()&#x20;

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

```java
conn.setupUI()
```

### startPurchaseTransaction(amount: )

Purchase is used to send the amount to the other Device

```java
conn.startPurchaseTransaction(amount: 300)
```

### resetSetting()

The reset setting is used to reset all the settings.

```java
conn.resetSetting()
```

### $showUI

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

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

## Example&#x20;

Please check the example

{% tabs %}
{% tab title="Swift UI" %}

```swift
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()
    }
}
```

{% endtab %}

{% tab title="UI Kit" %}

```swift
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)")
    }
    
    
}

```

{% endtab %}
{% endtabs %}
