commit | author | age
|
454098
|
1 |
/* |
L |
2 |
* Copyright 2018 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 |
|
|
19 |
#import "GULApplication.h" |
|
20 |
|
|
21 |
NS_ASSUME_NONNULL_BEGIN |
|
22 |
|
|
23 |
typedef NSString *const GULAppDelegateInterceptorID; |
|
24 |
|
|
25 |
/** This class contains methods that isa swizzle the app delegate. */ |
|
26 |
@interface GULAppDelegateSwizzler : NSProxy |
|
27 |
|
|
28 |
/** Registers an app delegate interceptor whose methods will be invoked as they're invoked on the |
|
29 |
* original app delegate. |
|
30 |
* |
|
31 |
* @param interceptor An instance of a class that conforms to the application delegate protocol. |
|
32 |
* The interceptor is NOT retained. |
|
33 |
* @return A unique GULAppDelegateInterceptorID if interceptor was successfully registered; nil |
|
34 |
* if it fails. |
|
35 |
*/ |
|
36 |
+ (nullable GULAppDelegateInterceptorID)registerAppDelegateInterceptor: |
|
37 |
(id<GULApplicationDelegate>)interceptor; |
|
38 |
|
|
39 |
/** Unregisters an interceptor with the given ID if it exists. |
|
40 |
* |
|
41 |
* @param interceptorID The object that was generated when the interceptor was registered. |
|
42 |
*/ |
|
43 |
+ (void)unregisterAppDelegateInterceptorWithID:(GULAppDelegateInterceptorID)interceptorID; |
|
44 |
|
|
45 |
/** This method ensures that the original app delegate has been proxied. Call this before |
|
46 |
* registering your interceptor. This method is safe to call multiple times (but it only proxies |
|
47 |
* the app delegate once). |
|
48 |
* |
|
49 |
* This method doesn't proxy APNS related methods: |
|
50 |
* @code |
|
51 |
* - application:didRegisterForRemoteNotificationsWithDeviceToken: |
|
52 |
* - application:didFailToRegisterForRemoteNotificationsWithError: |
|
53 |
* - application:didReceiveRemoteNotification:fetchCompletionHandler: |
|
54 |
* - application:didReceiveRemoteNotification: |
|
55 |
* @endcode |
|
56 |
* |
|
57 |
* To proxy these methods use +[GULAppDelegateSwizzler |
|
58 |
* proxyOriginalDelegateIncludingAPNSMethods]. The methods have to be proxied separately to |
|
59 |
* avoid potential warnings from Apple review about missing Push Notification Entitlement (e.g. |
|
60 |
* https://github.com/firebase/firebase-ios-sdk/issues/2807) |
|
61 |
* |
|
62 |
* The method has no effect for extensions. |
|
63 |
* |
|
64 |
* @see proxyOriginalDelegateIncludingAPNSMethods |
|
65 |
*/ |
|
66 |
+ (void)proxyOriginalDelegate; |
|
67 |
|
|
68 |
/** This method ensures that the original app delegate has been proxied including APNS related |
|
69 |
* methods. Call this before registering your interceptor. This method is safe to call multiple |
|
70 |
* times (but it only proxies the app delegate once) or |
|
71 |
* after +[GULAppDelegateSwizzler proxyOriginalDelegate] |
|
72 |
* |
|
73 |
* This method calls +[GULAppDelegateSwizzler proxyOriginalDelegate] under the hood. |
|
74 |
* After calling this method the following App Delegate methods will be proxied in addition to |
|
75 |
* the methods proxied by proxyOriginalDelegate: |
|
76 |
* @code |
|
77 |
* - application:didRegisterForRemoteNotificationsWithDeviceToken: |
|
78 |
* - application:didFailToRegisterForRemoteNotificationsWithError: |
|
79 |
* - application:didReceiveRemoteNotification:fetchCompletionHandler: |
|
80 |
* - application:didReceiveRemoteNotification: |
|
81 |
* @endcode |
|
82 |
* |
|
83 |
* The method has no effect for extensions. |
|
84 |
* |
|
85 |
* @see proxyOriginalDelegate |
|
86 |
*/ |
|
87 |
+ (void)proxyOriginalDelegateIncludingAPNSMethods; |
|
88 |
|
|
89 |
/** Indicates whether app delegate proxy is explicitly disabled or enabled. Enabled by default. |
|
90 |
* |
|
91 |
* @return YES if AppDelegateProxy is Enabled, NO otherwise. |
|
92 |
*/ |
|
93 |
+ (BOOL)isAppDelegateProxyEnabled; |
|
94 |
|
|
95 |
/** Returns the current sharedApplication. |
|
96 |
* |
|
97 |
* @return the current application instance if in an app, or nil if in extension or if it doesn't |
|
98 |
* exist. |
|
99 |
*/ |
|
100 |
+ (nullable GULApplication *)sharedApplication; |
|
101 |
|
|
102 |
/** Do not initialize this class. */ |
|
103 |
- (instancetype)init NS_UNAVAILABLE; |
|
104 |
|
|
105 |
NS_ASSUME_NONNULL_END |
|
106 |
|
|
107 |
@end |