1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45//
// RNViewManager.swift
// Hyperswitch
//
// Created by Shivam Shashank on 09/11/22.
//
import Foundation
import React
internal class RNViewManager: NSObject {
internal var responseHandler: RNResponseHandler?
internal var rootView: RCTRootView?
internal lazy var bridge: RCTBridge = {
RCTBridge.init(delegate: self, launchOptions: nil)
}()
internal static let sharedInstance = RNViewManager()
internal func viewForModule(_ moduleName: String, initialProperties: [String : Any]?) -> RCTRootView {
let rootView: RCTRootView = RCTRootView(
bridge: self.bridge,
moduleName: moduleName,
initialProperties: initialProperties)
self.rootView = rootView
return rootView
}
}
extension RNViewManager: RCTBridgeDelegate {
func sourceURL(for bridge: RCTBridge) -> URL? {
switch getInfoPlist("HyperswitchSource") {
case "LocalHosted":
return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
case "LocalBundle":
return Bundle.main.url(forResource: "hyperswitch", withExtension: "bundle")
default:
return OTAServices.shared.getBundleURL()
}
}
}