19
19
static DetoxAppDelegateProxy* _currentAppDelegateProxy;
20
20
static NSMutableArray <NSDictionary *>* _pendingOpenURLs;
21
21
static NSMutableArray <DetoxUserNotificationDispatcher*>* _pendingUserNotificationDispatchers;
22
+ static DetoxUserNotificationDispatcher* _pendingLaunchUserNotificationDispatcher;
23
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_10_3
22
24
static NSMutableArray <DetoxUserActivityDispatcher*>* _pendingUserActivityDispatchers;
23
25
static DetoxUserActivityDispatcher* _pendingLaunchUserActivityDispatcher;
24
- static DetoxUserNotificationDispatcher* _pendingLaunchUserNotificationDispatcher;
26
+ # endif
25
27
26
28
static COSTouchVisualizerWindow* _touchVisualizerWindow;
27
29
37
39
return [NSURL fileURLWithPath: userNotificationDataPath];
38
40
}
39
41
42
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_10_3
40
43
static NSURL * _launchUserActivityDataURL ()
41
44
{
42
45
NSString * userActivityDataPath = [[NSUserDefaults standardUserDefaults ] objectForKey: @" detoxUserActivityDataURL" ];
48
51
49
52
return [NSURL fileURLWithPath: userActivityDataPath];
50
53
}
54
+ #endif
51
55
52
56
@interface UIWindow (DTXEventProxy) @end
53
57
@@ -123,13 +127,18 @@ + (void)load
123
127
dispatch_once (&onceToken, ^{
124
128
_pendingOpenURLs = [NSMutableArray new ];
125
129
_pendingUserNotificationDispatchers = [NSMutableArray new ];
130
+
131
+ NSURL * url;
132
+
133
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_10_3
126
134
_pendingUserActivityDispatchers = [NSMutableArray new ];
127
135
128
- NSURL * url = _launchUserActivityDataURL ();
136
+ url = _launchUserActivityDataURL ();
129
137
if (url)
130
138
{
131
139
_pendingLaunchUserActivityDispatcher = [[DetoxUserActivityDispatcher alloc ] initWithUserActivityDataURL: url];
132
140
}
141
+ #endif
133
142
134
143
url = _launchUserNotificationDataURL ();
135
144
if (url)
@@ -188,7 +197,10 @@ - (NSString*)__dtx_sourceAppOverride
188
197
return [[NSUserDefaults standardUserDefaults ] objectForKey: @" detoxSourceAppOverride" ];
189
198
}
190
199
191
- - (NSDictionary *)__dtx_prepareLaunchOptions : (NSDictionary *)launchOptions userNotificationDispatcher : (DetoxUserNotificationDispatcher*)notificationDispatcher userActivityDispatcher : (DetoxUserActivityDispatcher*)activityDispatcher
200
+ - (NSDictionary *)__dtx_prepareLaunchOptions : (NSDictionary *)launchOptions userNotificationDispatcher : (DetoxUserNotificationDispatcher*)notificationDispatcher
201
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_10_3
202
+ userActivityDispatcher:(DetoxUserActivityDispatcher*)activityDispatcher
203
+ #endif
192
204
{
193
205
NSMutableDictionary * rv = [launchOptions mutableCopy ] ?: [NSMutableDictionary new ];
194
206
@@ -197,6 +209,7 @@ - (NSDictionary*)__dtx_prepareLaunchOptions:(NSDictionary*)launchOptions userNot
197
209
rv[UIApplicationLaunchOptionsRemoteNotificationKey] = [notificationDispatcher remoteNotification ];
198
210
}
199
211
212
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_10_3
200
213
if (activityDispatcher)
201
214
{
202
215
NSUserActivity * userActivity = [activityDispatcher userActivity ];
@@ -208,7 +221,7 @@ - (NSDictionary*)__dtx_prepareLaunchOptions:(NSDictionary*)launchOptions userNot
208
221
209
222
rv[UIApplicationLaunchOptionsUserActivityDictionaryKey] = userActivityDictionary;
210
223
}
211
-
224
+ # endif
212
225
213
226
NSURL * openURLOverride = [self __dtx_URLOverride ];
214
227
if (openURLOverride)
@@ -226,7 +239,11 @@ - (NSDictionary*)__dtx_prepareLaunchOptions:(NSDictionary*)launchOptions userNot
226
239
227
240
- (BOOL )application : (UIApplication *)application willFinishLaunchingWithOptions : (nullable NSDictionary <UIApplicationLaunchOptionsKey, id>*)launchOptions
228
241
{
229
- launchOptions = [self __dtx_prepareLaunchOptions: launchOptions userNotificationDispatcher: _pendingLaunchUserNotificationDispatcher userActivityDispatcher: _pendingLaunchUserActivityDispatcher];
242
+ launchOptions = [self __dtx_prepareLaunchOptions: launchOptions userNotificationDispatcher: _pendingLaunchUserNotificationDispatcher
243
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_10_3
244
+ userActivityDispatcher:_pendingLaunchUserActivityDispatcher
245
+ #endif
246
+ ];
230
247
231
248
BOOL rv = YES ;
232
249
if ([class_getSuperclass (object_getClass (self )) instancesRespondToSelector: _cmd ])
@@ -241,7 +258,11 @@ - (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:
241
258
242
259
- (BOOL )application : (UIApplication *)application didFinishLaunchingWithOptions : (nullable NSDictionary <UIApplicationLaunchOptionsKey, id> *)launchOptions
243
260
{
244
- launchOptions = [self __dtx_prepareLaunchOptions: launchOptions userNotificationDispatcher: _pendingLaunchUserNotificationDispatcher userActivityDispatcher: _pendingLaunchUserActivityDispatcher];
261
+ launchOptions = [self __dtx_prepareLaunchOptions: launchOptions userNotificationDispatcher: _pendingLaunchUserNotificationDispatcher
262
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_10_3
263
+ userActivityDispatcher:_pendingLaunchUserActivityDispatcher
264
+ #endif
265
+ ];
245
266
246
267
BOOL rv = YES ;
247
268
if ([class_getSuperclass (object_getClass (self )) instancesRespondToSelector: _cmd ])
@@ -252,10 +273,14 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
252
273
}
253
274
254
275
[_pendingLaunchUserNotificationDispatcher dispatchOnAppDelegate: self simulateDuringLaunch: YES ];
276
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_10_3
255
277
[_pendingLaunchUserActivityDispatcher dispatchOnAppDelegate: self ];
278
+ #endif
256
279
257
280
_pendingLaunchUserNotificationDispatcher = nil ;
281
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_10_3
258
282
_pendingLaunchUserActivityDispatcher = nil ;
283
+ #endif
259
284
260
285
if ([self __dtx_URLOverride ] && [class_getSuperclass (object_getClass (self )) instancesRespondToSelector: @selector (application:openURL:options: )])
261
286
{
@@ -285,10 +310,12 @@ - (void)applicationWillEnterForeground:(UIApplication *)application
285
310
}];
286
311
[_pendingUserNotificationDispatchers removeAllObjects ];
287
312
313
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_10_3
288
314
[_pendingUserActivityDispatchers enumerateObjectsUsingBlock: ^(DetoxUserActivityDispatcher * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
289
315
[self __dtx_actualDispatchUserActivityWithDispatcher: obj];
290
316
}];
291
317
[_pendingUserActivityDispatchers removeAllObjects ];
318
+ #endif
292
319
});
293
320
}
294
321
@@ -297,6 +324,7 @@ - (BOOL)touchVisualizerWindowShouldAlwaysShowFingertip:(COSTouchVisualizerWindow
297
324
return YES ;
298
325
}
299
326
327
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_10_3
300
328
- (void )__dtx_actualDispatchUserActivityWithDispatcher : (DetoxUserActivityDispatcher*)dispatcher
301
329
{
302
330
[dispatcher dispatchOnAppDelegate: self ];
@@ -315,6 +343,7 @@ - (void)__dtx_dispatchUserActivityFromDataURL:(NSURL*)userActivityDataURL delayU
315
343
[self __dtx_actualDispatchUserActivityWithDispatcher: dispatcher];
316
344
}
317
345
}
346
+ #endif
318
347
319
348
- (void )__dtx_actualDispatchUserNotificationWithDispatcher : (DetoxUserNotificationDispatcher*)dispatcher
320
349
{
0 commit comments