Skip to content

Commit

Permalink
🚀 Apply detaching more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Sep 18, 2024
1 parent e13c362 commit 1e9964d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions ios/Classes/PMNotificationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ @implementation PMNotificationManager {
BOOL isDetach;
}

- (void)dealloc {
[self detach];
}

- (instancetype)initWithRegistrar:
(NSObject <FlutterPluginRegistrar> *)registrar {
self = [super init];
Expand Down
11 changes: 6 additions & 5 deletions ios/Classes/PMPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,19 @@ - (void)registerPlugin:(NSObject <FlutterPluginRegistrar> *)registrar {
}];
}

- (void)dealloc {
- (void)detach {
privateRegistrar = nil;
isDetach = YES;
[channel setMethodCallHandler:nil];
[self.notificationManager detach];
}

- (void)dealloc {
[self detach];
}

- (void)applicationWillTerminate:(NSNotification *)notification {
privateRegistrar = nil;
isDetach = YES;
[channel setMethodCallHandler:nil];
[self.notificationManager detach];
[self detach];
}

- (void)initNotificationManager:(NSObject <FlutterPluginRegistrar> *)registrar {
Expand Down

0 comments on commit 1e9964d

Please sign in to comment.