Skip to content
Open
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
97 changes: 79 additions & 18 deletions airborne-react-native/example/ios/AirborneExample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,59 +27,100 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Create the main window early
self.window = UIWindow(frame: UIScreen.main.bounds)

// let delegate = ReactNativeDelegate(customPath: bundlePath)
// let factory = RCTReactNativeFactory(delegate: delegate)
// delegate.dependencyProvider = RCTAppDependencyProvider()
//
// reactNativeDelegate = delegate
// reactNativeFactory = factory
//
// factory.startReactNative(
// withModuleName: "AirborneExample",
// in: window,
// launchOptions: self.launchOptions
// )


// let delegate = ReactNativeDelegate()
// let factory = RCTReactNativeFactory(delegate: delegate)
// delegate.dependencyProvider = RCTAppDependencyProvider()
//
// reactNativeDelegate = delegate
// reactNativeFactory = factory
//
// window = UIWindow(frame: UIScreen.main.bounds)
//
// factory.startReactNative(
// withModuleName: "AirborneExample",
// in: window,
// launchOptions: launchOptions
// )

return true
}

private func initializeHyperOTA() {
airborne = Airborne(releaseConfigURL: "https://airborne.sandbox.juspay.in/release/airborne-react-example/ios", delegate: self)
airborne = Airborne(releaseConfigURL: "http://127.0.0.1:8080/release_config.json", delegate: self)
print("HyperOTA: Initialized successfully")
}
}

extension AppDelegate: AirborneDelegate {

func getNamespace() -> String {
func namespace() -> String {
return "airborneexample"
}

func getBundle() -> Bundle {
return Bundle.main
func bundle() -> Bundle {
guard
let bundleURL = Bundle.main.url(forResource: "airborneex", withExtension: "bundle"),
let bundle = Bundle(url: bundleURL)
else {
fatalError("❌ Could not find airborneex.bundle in main bundle.")
}

return bundle
}

func getDimensions() -> [String : String] {
func dimensions() -> [String : String] {
return [:]
}

func onEvent(level: String, label: String, key: String, value: [String : Any], category: String, subcategory: String) {
print("Event: \(key) = \(value)")
}

func startApp(_ bundlePath: String) {

func startApp(indexBundleURL: URL) -> Void {
DispatchQueue.main.async { [self] in

let delegate = ReactNativeDelegate(customPath: bundlePath)
let bundlePath = indexBundleURL.absoluteString

print("In start APP \(bundlePath)")
let delegate = ReactNativeDelegate(bundleURL: indexBundleURL)
let factory = RCTReactNativeFactory(delegate: delegate)
delegate.dependencyProvider = RCTAppDependencyProvider()

reactNativeDelegate = delegate
reactNativeFactory = factory

factory.startReactNative(
withModuleName: "AirborneExample",
in: window,
launchOptions: self.launchOptions
)

}
}

}

class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {

private let customPath: String
private let bundleUrl: URL

init(customPath: String) {
self.customPath = customPath
init(bundleURL: URL) {
self.bundleUrl = bundleURL
super.init()
}

Expand All @@ -88,10 +129,30 @@ class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
}

override func bundleURL() -> URL? {
#if DEBUG
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
#else
URL(fileURLWithPath: customPath)
#endif

// if let bundleURL = Bundle.main.url(forResource: "airborneex", withExtension: "bundle") {
// return bundleURL.appendingPathComponent("main.jsbundle")
// }

return self.bundleUrl
}
}

//class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
// override func sourceURL(for bridge: RCTBridge) -> URL? {
// self.bundleURL()
// }
//
// override func bundleURL() -> URL? {
//
// if let bundleURL = Bundle.main.url(forResource: "airborneex", withExtension: "bundle") {
// return bundleURL.appendingPathComponent("main.jsbundle")
// }
//
//#if DEBUG
// RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
//#else
// return Bundle.main.url(forResource: "main", withExtension: "jsbundle")
//#endif
// }
//}
2 changes: 2 additions & 0 deletions airborne-react-native/example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ target 'AirborneExample' do
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)

pod 'FLEX', :configurations => ['Debug']

post_install do |installer|
# https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
Expand Down
Loading
Loading