Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions ios/src/PlaidEmbeddedSearchView.swift
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import ExpoModulesCore
import UIKit
internal import LinkKit
import UIKit

class PlaidEmbeddedSearchView: ExpoView {
private var embeddedView: EmbeddedSearchUIView?

let onSuccess = EventDispatcher()
let onExit = EventDispatcher()
let onEvent = EventDispatcher()
let onLoad = EventDispatcher()

required init(appContext: AppContext? = nil) {
super.init(appContext: appContext)
clipsToBounds = true
}

func setToken(_ token: String) {
embeddedView?.removeFromSuperview()
embeddedView = nil

let configuration = EmbeddedLinkTokenConfiguration(
token: token,
onSuccess: { [weak self] linkSuccess in
Expand All @@ -31,7 +31,7 @@ class PlaidEmbeddedSearchView: ExpoView {
self?.onEvent(linkEvent.asDictionary)
}
)

guard let viewController = appContext?.utilities?.currentViewController() else {
let errorExit: [String: Any] = [
"error": [
Expand All @@ -47,32 +47,32 @@ class PlaidEmbeddedSearchView: ExpoView {
"status": NSNull(),
"requestId": NSNull(),
"metadataJson": NSNull(),
]
],
]
self.onExit(errorExit)
return
}

do {
let plaidEmbeddedView = try Plaid.createEmbeddedLinkUIView(
configuration: configuration,
presentationMethod: .viewController(viewController)
)

self.embeddedView = plaidEmbeddedView

plaidEmbeddedView.translatesAutoresizingMaskIntoConstraints = false
addSubview(plaidEmbeddedView)

NSLayoutConstraint.activate([
plaidEmbeddedView.topAnchor.constraint(equalTo: topAnchor),
plaidEmbeddedView.leadingAnchor.constraint(equalTo: leadingAnchor),
plaidEmbeddedView.trailingAnchor.constraint(equalTo: trailingAnchor),
plaidEmbeddedView.bottomAnchor.constraint(equalTo: bottomAnchor),
])

self.onLoad([:])

} catch {
let errorExit: [String: Any] = [
"error": [
Expand All @@ -88,12 +88,12 @@ class PlaidEmbeddedSearchView: ExpoView {
"status": NSNull(),
"requestId": NSNull(),
"metadataJson": NSNull(),
]
],
]
self.onExit(errorExit)
}
}

override func layoutSubviews() {
super.layoutSubviews()
embeddedView?.frame = bounds
Expand Down
19 changes: 19 additions & 0 deletions ios/src/RNPlaidLinkSdkVersion.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Foundation

/// Objective-C-compatible shim class that exposes the React Native SDK version.
///
/// This class serves two purposes:
/// 1. Provides a version constant for the Expo module to expose to JavaScript
/// 2. Enables runtime detection from native iOS code (backward compatibility)
///
/// The version should be manually updated to match the version in package.json
/// when releasing new versions of the React Native SDK.
@objc(RNPlaidLinkSdkVersion)
public class RNPlaidLinkSdkVersion: NSObject {

/// The React Native Plaid Link SDK version.
///
/// This should match the version specified in package.json.
/// Update this value when bumping the SDK version.
@objc public static let sdkVersion: String = "13.0.0"
}
Loading
Loading