11
11
#import " flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h"
12
12
#import " flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate_internal.h"
13
13
14
+ FLUTTER_ASSERT_ARC
15
+
14
16
static NSString * const kUIBackgroundMode = @" UIBackgroundModes" ;
15
17
static NSString * const kRemoteNotificationCapabitiliy = @" remote-notification" ;
16
18
static NSString * const kBackgroundFetchCapatibility = @" fetch" ;
17
19
static NSString * const kRestorationStateAppModificationKey = @" mod-date" ;
18
20
19
21
@interface FlutterAppDelegate ()
20
22
@property (nonatomic , copy ) FlutterViewController* (^rootFlutterViewControllerGetter)(void );
23
+ @property (nonatomic , strong ) FlutterPluginAppLifeCycleDelegate* lifeCycleDelegate;
21
24
@end
22
25
23
- @implementation FlutterAppDelegate {
24
- FlutterPluginAppLifeCycleDelegate* _lifeCycleDelegate;
25
- }
26
+ @implementation FlutterAppDelegate
26
27
27
28
- (instancetype )init {
28
29
if (self = [super init ]) {
@@ -31,21 +32,16 @@ - (instancetype)init {
31
32
return self;
32
33
}
33
34
34
- - (void )dealloc {
35
- [_lifeCycleDelegate release ];
36
- [_rootFlutterViewControllerGetter release ];
37
- [_window release ];
38
- [super dealloc ];
39
- }
40
-
41
35
- (BOOL )application : (UIApplication*)application
42
36
willFinishLaunchingWithOptions : (NSDictionary *)launchOptions {
43
- return [_lifeCycleDelegate application: application willFinishLaunchingWithOptions: launchOptions];
37
+ return [self .lifeCycleDelegate application: application
38
+ willFinishLaunchingWithOptions: launchOptions];
44
39
}
45
40
46
41
- (BOOL )application : (UIApplication*)application
47
42
didFinishLaunchingWithOptions : (NSDictionary *)launchOptions {
48
- return [_lifeCycleDelegate application: application didFinishLaunchingWithOptions: launchOptions];
43
+ return [self .lifeCycleDelegate application: application
44
+ didFinishLaunchingWithOptions: launchOptions];
49
45
}
50
46
51
47
// Returns the key window's rootViewController, if it's a FlutterViewController.
@@ -85,39 +81,39 @@ - (void)applicationWillTerminate:(UIApplication*)application {
85
81
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
86
82
- (void )application : (UIApplication*)application
87
83
didRegisterUserNotificationSettings : (UIUserNotificationSettings*)notificationSettings {
88
- [_lifeCycleDelegate application: application
84
+ [self .lifeCycleDelegate application: application
89
85
didRegisterUserNotificationSettings: notificationSettings];
90
86
}
91
87
#pragma GCC diagnostic pop
92
88
93
89
- (void )application : (UIApplication*)application
94
90
didRegisterForRemoteNotificationsWithDeviceToken : (NSData *)deviceToken {
95
- [_lifeCycleDelegate application: application
91
+ [self .lifeCycleDelegate application: application
96
92
didRegisterForRemoteNotificationsWithDeviceToken: deviceToken];
97
93
}
98
94
99
95
- (void )application : (UIApplication*)application
100
96
didFailToRegisterForRemoteNotificationsWithError : (NSError *)error {
101
- [_lifeCycleDelegate application: application
97
+ [self .lifeCycleDelegate application: application
102
98
didFailToRegisterForRemoteNotificationsWithError: error];
103
99
}
104
100
105
101
#pragma GCC diagnostic push
106
102
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
107
103
- (void )application : (UIApplication*)application
108
104
didReceiveLocalNotification : (UILocalNotification*)notification {
109
- [_lifeCycleDelegate application: application didReceiveLocalNotification: notification];
105
+ [self .lifeCycleDelegate application: application didReceiveLocalNotification: notification];
110
106
}
111
107
#pragma GCC diagnostic pop
112
108
113
109
- (void )userNotificationCenter : (UNUserNotificationCenter *)center
114
110
willPresentNotification : (UNNotification *)notification
115
111
withCompletionHandler :
116
112
(void (^)(UNNotificationPresentationOptions options))completionHandler {
117
- if ([_lifeCycleDelegate respondsToSelector: _cmd ]) {
118
- [_lifeCycleDelegate userNotificationCenter: center
119
- willPresentNotification: notification
120
- withCompletionHandler: completionHandler];
113
+ if ([self .lifeCycleDelegate respondsToSelector: _cmd ]) {
114
+ [self .lifeCycleDelegate userNotificationCenter: center
115
+ willPresentNotification: notification
116
+ withCompletionHandler: completionHandler];
121
117
}
122
118
}
123
119
@@ -127,10 +123,10 @@ - (void)userNotificationCenter:(UNUserNotificationCenter*)center
127
123
- (void )userNotificationCenter : (UNUserNotificationCenter *)center
128
124
didReceiveNotificationResponse : (UNNotificationResponse *)response
129
125
withCompletionHandler : (void (^)(void ))completionHandler {
130
- if ([_lifeCycleDelegate respondsToSelector: _cmd ]) {
131
- [_lifeCycleDelegate userNotificationCenter: center
132
- didReceiveNotificationResponse: response
133
- withCompletionHandler: completionHandler];
126
+ if ([self .lifeCycleDelegate respondsToSelector: _cmd ]) {
127
+ [self .lifeCycleDelegate userNotificationCenter: center
128
+ didReceiveNotificationResponse: response
129
+ withCompletionHandler: completionHandler];
134
130
}
135
131
}
136
132
@@ -145,7 +141,7 @@ - (BOOL)isFlutterDeepLinkingEnabled {
145
141
- (BOOL )application : (UIApplication*)application
146
142
openURL : (NSURL *)url
147
143
options : (NSDictionary <UIApplicationOpenURLOptionsKey, id>*)options {
148
- if ([_lifeCycleDelegate application: application openURL: url options: options]) {
144
+ if ([self .lifeCycleDelegate application: application openURL: url options: options]) {
149
145
return YES ;
150
146
}
151
147
@@ -178,31 +174,31 @@ - (BOOL)handleOpenURL:(NSURL*)url
178
174
}
179
175
180
176
- (BOOL )application : (UIApplication*)application handleOpenURL : (NSURL *)url {
181
- return [_lifeCycleDelegate application: application handleOpenURL: url];
177
+ return [self .lifeCycleDelegate application: application handleOpenURL: url];
182
178
}
183
179
184
180
- (BOOL )application : (UIApplication*)application
185
181
openURL : (NSURL *)url
186
182
sourceApplication : (NSString *)sourceApplication
187
183
annotation : (id )annotation {
188
- return [_lifeCycleDelegate application: application
189
- openURL: url
190
- sourceApplication: sourceApplication
191
- annotation: annotation];
184
+ return [self .lifeCycleDelegate application: application
185
+ openURL: url
186
+ sourceApplication: sourceApplication
187
+ annotation: annotation];
192
188
}
193
189
194
190
- (void )application : (UIApplication*)application
195
191
performActionForShortcutItem : (UIApplicationShortcutItem*)shortcutItem
196
192
completionHandler : (void (^)(BOOL succeeded))completionHandler {
197
- [_lifeCycleDelegate application: application
198
- performActionForShortcutItem: shortcutItem
199
- completionHandler: completionHandler];
193
+ [self .lifeCycleDelegate application: application
194
+ performActionForShortcutItem: shortcutItem
195
+ completionHandler: completionHandler];
200
196
}
201
197
202
198
- (void )application : (UIApplication*)application
203
199
handleEventsForBackgroundURLSession : (nonnull NSString *)identifier
204
200
completionHandler : (nonnull void (^)())completionHandler {
205
- [_lifeCycleDelegate application: application
201
+ [self .lifeCycleDelegate application: application
206
202
handleEventsForBackgroundURLSession: identifier
207
203
completionHandler: completionHandler];
208
204
}
@@ -213,9 +209,9 @@ - (BOOL)application:(UIApplication*)application
213
209
restorationHandler :
214
210
(void (^)(NSArray <id<UIUserActivityRestoring>>* __nullable restorableObjects))
215
211
restorationHandler {
216
- if ([_lifeCycleDelegate application: application
217
- continueUserActivity: userActivity
218
- restorationHandler: restorationHandler]) {
212
+ if ([self .lifeCycleDelegate application: application
213
+ continueUserActivity: userActivity
214
+ restorationHandler: restorationHandler]) {
219
215
return YES ;
220
216
}
221
217
@@ -251,30 +247,30 @@ - (NSObject*)valuePublishedByPlugin:(NSString*)pluginKey {
251
247
#pragma mark - Selectors handling
252
248
253
249
- (void )addApplicationLifeCycleDelegate : (NSObject <FlutterApplicationLifeCycleDelegate>*)delegate {
254
- [_lifeCycleDelegate addDelegate: delegate];
250
+ [self .lifeCycleDelegate addDelegate: delegate];
255
251
}
256
252
257
253
#pragma mark - UIApplicationDelegate method dynamic implementation
258
254
259
255
- (BOOL )respondsToSelector : (SEL )selector {
260
- if ([_lifeCycleDelegate isSelectorAddedDynamically: selector]) {
256
+ if ([self .lifeCycleDelegate isSelectorAddedDynamically: selector]) {
261
257
return [self delegateRespondsSelectorToPlugins: selector];
262
258
}
263
259
return [super respondsToSelector: selector];
264
260
}
265
261
266
262
- (BOOL )delegateRespondsSelectorToPlugins : (SEL )selector {
267
- if ([_lifeCycleDelegate hasPluginThatRespondsToSelector: selector]) {
268
- return [_lifeCycleDelegate respondsToSelector: selector];
263
+ if ([self .lifeCycleDelegate hasPluginThatRespondsToSelector: selector]) {
264
+ return [self .lifeCycleDelegate respondsToSelector: selector];
269
265
} else {
270
266
return NO ;
271
267
}
272
268
}
273
269
274
270
- (id )forwardingTargetForSelector : (SEL )aSelector {
275
- if ([_lifeCycleDelegate isSelectorAddedDynamically: aSelector]) {
271
+ if ([self .lifeCycleDelegate isSelectorAddedDynamically: aSelector]) {
276
272
[self logCapabilityConfigurationWarningIfNeeded: aSelector];
277
- return _lifeCycleDelegate ;
273
+ return self. lifeCycleDelegate ;
278
274
}
279
275
return [super forwardingTargetForSelector: aSelector];
280
276
}
@@ -286,7 +282,7 @@ - (id)forwardingTargetForSelector:(SEL)aSelector {
286
282
- (void )logCapabilityConfigurationWarningIfNeeded : (SEL )selector {
287
283
NSArray * backgroundModesArray =
288
284
[[NSBundle mainBundle ] objectForInfoDictionaryKey: kUIBackgroundMode ];
289
- NSSet * backgroundModesSet = [[[ NSSet alloc ] initWithArray: backgroundModesArray] autorelease ];
285
+ NSSet * backgroundModesSet = [[NSSet alloc ] initWithArray: backgroundModesArray];
290
286
if (selector == @selector (application:didReceiveRemoteNotification:fetchCompletionHandler: )) {
291
287
if (![backgroundModesSet containsObject: kRemoteNotificationCapabitiliy ]) {
292
288
NSLog (
0 commit comments