QuilttConnector

0.0.8

Quiltt iOS SDK
quiltt/quiltt-ios

What's New

0.0.8

2024-05-14T13:25:06Z

What's Changed

Full Changelog: 0.0.7...0.0.8

Quiltt iOS SDK

Install

Swift Package Manager

  1. Open your project in Xcode.
  2. Select File > Add Package Dependency....
  3. Enter the URL of the Quiltt Connector Swift SDK repository, select the latest version and click Add Package.
  4. The Quiltt Connector Swift SDK is now integrated into your project. You can import it in your Swift files with import QuilttConnector.

Usage

After importing QuilttConnector, you can use its classes and methods in your code. Here's a basic example:

import SwiftUI
import QuilttConnector
import WebKit

struct ConnectorView: View {
    @Binding var showHomeView: Bool
    @Binding var connectionId: String
    var body: some View {
        WebView(showHomeView: $showHomeView, connectionId: $connectionId)
    }
}

struct WebView: UIViewRepresentable {
    @Binding var showHomeView: Bool
    @Binding var connectionId: String
    @State var config = QuilttConnectorConnectConfiguration(
        connectorId: "<CONNECTOR_ID>",
        oauthRedirectUrl: "<YOUR_HTTPS_UNIVERSAL_LINK>"
    )

    func makeUIView(context: Context) -> WKWebView {
        let quilttConnector = QuilttConnector.init()
        quilttConnector.authenticate(token: "<SESSION_TOKEN>")
        let webview = quilttConnector.connect(config: config,
                                              onEvent: { eventType, metadata in
                                                print("onEvent \(eventType), \(metadata)")
                                              },
                                              onExitSuccess: { metadata in
                                                print("onExitSuccess \(metadata)")
                                                connectionId = metadata.connectionId!
                                                showHomeView = true
                                              },
                                              onExitAbort: { metadata in
                                                print("onExitAbort \(metadata)")
                                                showHomeView = true
                                              },
                                              onExitError: { metadata in
                                                print("onExitError \(metadata)")
                                                showHomeView = true
                                              })
        return webview
    }

    func updateUIView(_ uiView: WKWebView, context: Context) {
        // Use this method to update the WKWebView with new configuration settings.
    }
}

#Preview {
    ConnectorView(showHomeView: .constant(false), connectionId: .constant("connectionId"))
}

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri Nov 08 2024 14:28:14 GMT-1000 (Hawaii-Aleutian Standard Time)