@@ -135,6 +135,48 @@ class FulaModule: NSObject {
135135 return convertIntToByte ( keyInt)
136136 }
137137
138+ @objc func registerLifecycleListener( ) {
139+ NotificationCenter . default. addObserver (
140+ self ,
141+ selector: #selector( applicationWillResignActive) ,
142+ name: UIApplication . willResignActiveNotification,
143+ object: nil )
144+
145+ NotificationCenter . default. addObserver (
146+ self ,
147+ selector: #selector( applicationDidEnterBackground) ,
148+ name: UIApplication . didEnterBackgroundNotification,
149+ object: nil )
150+
151+ NotificationCenter . default. addObserver (
152+ self ,
153+ selector: #selector( applicationWillTerminate) ,
154+ name: UIApplication . willTerminateNotification,
155+ object: nil )
156+ }
157+
158+ deinit {
159+ NotificationCenter . default. removeObserver ( self )
160+ }
161+
162+ @objc func applicationWillResignActive( ) {
163+ // Handle app will resign active (similar to onHostPause)
164+ }
165+
166+ @objc func applicationDidEnterBackground( ) {
167+ // Handle app entered background
168+ }
169+
170+ @objc func applicationWillTerminate( ) {
171+ // Attempt to shut down Fula cleanly (similar to onHostDestroy)
172+ do {
173+ try shutdownInternal ( )
174+ } catch {
175+ print ( " Error shutting down Fula: \( error) " )
176+ }
177+ }
178+
179+
138180 @objc ( checkConnection: withResolver: withRejecter: )
139181 func checkConnection( timeout: NSNumber , resolve: @escaping RCTPromiseResolveBlock , reject: @escaping RCTPromiseRejectBlock ) {
140182 OSLog . viewCycle. info ( " ReactNative checkConnection started with timeout= \( timeout) " )
0 commit comments