@@ -9,9 +9,7 @@ @interface RNSwanBrowser() <SFSafariViewControllerDelegate, UIAdaptivePresentati
99
1010@end
1111
12- @implementation RNSwanBrowser {
13- bool hasListeners;
14- }
12+ @implementation RNSwanBrowser
1513
1614RCT_EXPORT_MODULE ();
1715
@@ -23,24 +21,9 @@ - (dispatch_queue_t)methodQueue {
2321 return dispatch_get_main_queue ();
2422}
2523
26- - (void )startObserving {
27- hasListeners = YES ;
28- }
29-
30- - (void )stopObserving {
31- hasListeners = NO ;
32- }
33-
34- - (NSArray <NSString *> *)supportedEvents {
35- return @[@" swanBrowserDidClose" ];
36- }
37-
3824- (void )handleOnClose {
3925 _safariVC = nil ;
40-
41- if (hasListeners) {
42- [self sendEventWithName: @" swanBrowserDidClose" body: nil ];
43- }
26+ [self emitOnClose: true ];
4427}
4528
4629- (void )presentationControllerDidDismiss : (UIPresentationController *)controller {
@@ -51,7 +34,6 @@ - (void)safariViewControllerDidFinish:(SFSafariViewController *)controller {
5134 [self handleOnClose ];
5235}
5336
54- #ifdef RCT_NEW_ARCH_ENABLED
5537- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule : (const facebook::react::ObjCTurboModule::InitParams &)params {
5638 return std::make_shared<facebook::react::NativeRNSwanBrowserSpecJSI>(params);
5739}
@@ -66,18 +48,6 @@ - (void)open:(NSString *)url
6648 NSNumber *barTintColor = options.barTintColor ().has_value () ? [NSNumber numberWithDouble: options.barTintColor ().value ()] : nil ;
6749 NSNumber *controlTintColor = options.controlTintColor ().has_value () ? [NSNumber numberWithDouble: options.controlTintColor ().value ()] : nil ;
6850
69- #else
70- RCT_EXPORT_METHOD (open:(NSString *)url
71- options:(NSDictionary * _Nonnull)options
72- resolve:(RCTPromiseResolveBlock)resolve
73- reject:(RCTPromiseRejectBlock)reject) {
74-
75- NSString *animationType = [options valueForKey: @" animationType" ];
76- NSString *dismissButtonStyle = [options valueForKey: @" dismissButtonStyle" ];
77- NSNumber *barTintColor = [options valueForKey: @" barTintColor" ];
78- NSNumber *controlTintColor = [options valueForKey: @" controlTintColor" ];
79-
80- #endif
8151 if (_safariVC != nil ) {
8252 return reject (@" swan_browser_visible" , @" An instance of the swan browser is already visible" , nil );
8353 }
@@ -123,11 +93,7 @@ - (void)open:(NSString *)url
12393 }
12494}
12595
126- #ifdef RCT_NEW_ARCH_ENABLED
12796- (void )close {
128- #else
129- RCT_EXPORT_METHOD (close) {
130- #endif
13197 if (_safariVC != nil ) {
13298 [RCTPresentedViewController () dismissViewControllerAnimated: true completion: ^{
13399 [self handleOnClose ];
0 commit comments