diff --git a/ios/Classes/AblyFlutter.h b/ios/Classes/AblyFlutter.h index c53d520a6..a633950de 100644 --- a/ios/Classes/AblyFlutter.h +++ b/ios/Classes/AblyFlutter.h @@ -25,14 +25,7 @@ NS_ASSUME_NONNULL_BEGIN -(ARTPaginatedResult *) getPaginatedResult:(NSNumber *const) handle; -/** - This method must be called from the main dispatch queue. It may only be called - once. - - @param completionHandler Will be called on the main dispatch queue when all - platform objects have been closed down cleanly. - */ --(void)disposeWithCompletionHandler:(dispatch_block_t)completionHandler; +-(void)dispose; @end diff --git a/ios/Classes/AblyFlutter.m b/ios/Classes/AblyFlutter.m index 599ba47ac..721c29be6 100644 --- a/ios/Classes/AblyFlutter.m +++ b/ios/Classes/AblyFlutter.m @@ -126,21 +126,6 @@ -(ARTPaginatedResult *) getPaginatedResult:(NSNumber *const) handle { return [_paginatedResults objectForKey:handle]; } --(void)disposeWithCompletionHandler:(const dispatch_block_t)completionHandler { - if (!completionHandler) { - [NSException raise:NSInvalidArgumentException format:@"completionHandler cannot be nil."]; - } - - dispatch_assert_queue(dispatch_get_main_queue()); - - // This is contrived for now but the point is that we can introduce a clean, - // asynchronous close via a background queue here if required. - dispatch_async(dispatch_get_main_queue(), ^{ - [self dispose]; - completionHandler(); - }); -} - -(void)dispose { for (ARTRealtime *const r in _realtimeInstances.allValues) { [r close]; diff --git a/ios/Classes/AblyFlutterPlugin.m b/ios/Classes/AblyFlutterPlugin.m index ac4a63b74..24c97f67a 100644 --- a/ios/Classes/AblyFlutterPlugin.m +++ b/ios/Classes/AblyFlutterPlugin.m @@ -22,7 +22,7 @@ static FlutterHandle declarations. */ @interface AblyFlutterPlugin () --(void)registerWithCompletionHandler:(FlutterResult)completionHandler; +-(void)reset; @end NS_ASSUME_NONNULL_END @@ -36,7 +36,8 @@ -(void)registerWithCompletionHandler:(FlutterResult)completionHandler; }; static const FlutterHandler _resetAblyClients = ^void(AblyFlutterPlugin *const plugin, FlutterMethodCall *const call, const FlutterResult result) { - [plugin registerWithCompletionHandler:result]; + [plugin reset]; + result(nil); }; static const FlutterHandler _createRestWithOptions = ^void(AblyFlutterPlugin *const plugin, FlutterMethodCall *const call, const FlutterResult result) { @@ -652,14 +653,9 @@ -(void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { } } --(void)registerWithCompletionHandler:(const FlutterResult)completionHandler { - if (!completionHandler) { - [NSException raise:NSInvalidArgumentException format:@"completionHandler cannot be nil."]; - } - [_ably disposeWithCompletionHandler:^{ - [self->_streamsChannel reset]; - completionHandler(nil); - }]; +-(void)reset { + [_ably dispose]; + [self->_streamsChannel reset]; } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {