commit | author | age
|
454098
|
1 |
/* |
L |
2 |
* Copyright 2019 Google LLC |
|
3 |
* |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
*/ |
|
16 |
|
|
17 |
#import <Foundation/Foundation.h> |
|
18 |
#import <TargetConditionals.h> |
|
19 |
|
|
20 |
#if !TARGET_OS_OSX |
|
21 |
#import <UIKit/UIKit.h> |
|
22 |
#endif // !TARGET_OS_OSX |
|
23 |
|
|
24 |
#if ((TARGET_OS_IOS || TARGET_OS_TV) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 130000)) |
|
25 |
#define UISCENE_SUPPORTED 1 |
|
26 |
#endif |
|
27 |
|
|
28 |
NS_ASSUME_NONNULL_BEGIN |
|
29 |
|
|
30 |
typedef NSString *const GULSceneDelegateInterceptorID; |
|
31 |
|
|
32 |
/** This class contains methods that isa swizzle the scene delegate. */ |
|
33 |
@interface GULSceneDelegateSwizzler : NSProxy |
|
34 |
|
|
35 |
#if UISCENE_SUPPORTED |
|
36 |
|
|
37 |
/** Registers a scene delegate interceptor whose methods will be invoked as they're invoked on the |
|
38 |
* original scene delegate. |
|
39 |
* |
|
40 |
* @param interceptor An instance of a class that conforms to the application delegate protocol. |
|
41 |
* The interceptor is NOT retained. |
|
42 |
* @return A unique GULSceneDelegateInterceptorID if interceptor was successfully registered; nil |
|
43 |
* if it fails. |
|
44 |
*/ |
|
45 |
+ (nullable GULSceneDelegateInterceptorID)registerSceneDelegateInterceptor: |
|
46 |
(id<UISceneDelegate>)interceptor API_AVAILABLE(ios(13.0), tvos(13.0)); |
|
47 |
|
|
48 |
/** Unregisters an interceptor with the given ID if it exists. |
|
49 |
* |
|
50 |
* @param interceptorID The object that was generated when the interceptor was registered. |
|
51 |
*/ |
|
52 |
+ (void)unregisterSceneDelegateInterceptorWithID:(GULSceneDelegateInterceptorID)interceptorID |
|
53 |
API_AVAILABLE(ios(13.0), tvos(13.0)); |
|
54 |
|
|
55 |
/** Do not initialize this class. */ |
|
56 |
- (instancetype)init NS_UNAVAILABLE; |
|
57 |
|
|
58 |
#endif // UISCENE_SUPPORTED |
|
59 |
|
|
60 |
/** This method ensures that the original scene delegate has been proxied. Call this before |
|
61 |
* registering your interceptor. This method is safe to call multiple times (but it only proxies |
|
62 |
* the scene delegate once). |
|
63 |
* |
|
64 |
* The method has no effect for extensions. |
|
65 |
*/ |
|
66 |
+ (void)proxyOriginalSceneDelegate; |
|
67 |
|
|
68 |
/** Indicates whether scene delegate proxy is explicitly disabled or enabled. Enabled by default. |
|
69 |
* |
|
70 |
* @return YES if SceneDelegateProxy is Enabled, NO otherwise. |
|
71 |
*/ |
|
72 |
+ (BOOL)isSceneDelegateProxyEnabled; |
|
73 |
|
|
74 |
@end |
|
75 |
|
|
76 |
NS_ASSUME_NONNULL_END |