QuilttConnector

0.0.7

Quiltt iOS SDK
quiltt/quiltt-ios

What's New

0.0.7

2024-04-30T21:16:35Z

What's Changed

New Contributors

Full Changelog: 0.0.6...0.0.7

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: Sat May 04 2024 00:35:26 GMT-0900 (Hawaii-Aleutian Daylight Time)