File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ @implementation UIApplication (FIRFBI)
286286
+ (void)load {
287287
// C++ constructors may not be called yet so call NSLog rather than LogDebug.
288288
NSLog(@"Loading UIApplication category for Firebase App");
289-
::firebase::util::RunOnAppDelegate(^(Class clazz) { // Renamed here
289+
::firebase::util::RunOnAppDelegateClasses(^(Class clazz) {
290290
::firebase::invites::HookAppDelegateMethods(clazz);
291291
});
292292
}
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,12 @@ typedef BOOL (
185185
id self, SEL selector_value, UIApplication *application,
186186
NSUserActivity *user_activity, void (^restoration_handler)(NSArray *));
187187

188-
// Call the given block once for every Objective-C class that exists that
189-
// implements the UIApplicationDelegate protocol (except for those in a
190-
// blacklist we keep).
191-
void RunOnAppDelegate(void (^block)(Class));
188+
// Calls the given block for each unique Objective-C class that has been
189+
// previously passed to [UIApplication setDelegate:]. The block is executed
190+
// immediately for all currently known unique delegate classes.
191+
// Additionally, the block is queued to be executed if any new, unique
192+
// Objective-C class is passed to [UIApplication setDelegate:] in the future.
193+
void RunOnAppDelegateClasses(void (^block)(Class));
192194

193195
// Convert a string array into an NSMutableArray.
194196
NSMutableArray *StringVectorToNSMutableArray(
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#define MAX_SEEN_DELEGATE_CLASSES 32
3030

3131
static IMP g_original_setDelegate_imp = NULL;
32-
// static Class g_app_delegate_class = nil; // Removed
3332
static void (^g_pending_app_delegate_blocks[MAX_PENDING_APP_DELEGATE_BLOCKS])(Class) = {nil};
3433
static int g_pending_block_count = 0;
3534

@@ -169,9 +168,9 @@ - (BOOL)application:(UIApplication *)application
169168
namespace firebase {
170169
namespace util {
171170

172-
void RunOnAppDelegate(void (^block)(Class)) {
171+
void RunOnAppDelegateClasses(void (^block)(Class)) {
173172
if (g_seen_delegate_classes_count > 0) {
174-
NSLog(@"Firebase: RunOnAppDelegate executing block for %d already seen delegate class(es).",
173+
NSLog(@"Firebase: RunOnAppDelegateClasses executing block for %d already seen delegate class(es).",
175174
g_seen_delegate_classes_count);
176175
for (int i = 0; i < g_seen_delegate_classes_count; i++) {
177176
// Assuming classes in g_seen_delegate_classes up to count are non-nil
@@ -180,17 +179,17 @@ void RunOnAppDelegate(void (^block)(Class)) {
180179
}
181180
}
182181
} else {
183-
NSLog(@"Firebase: RunOnAppDelegate - no delegate classes seen yet. Block will be queued for future delegates.");
182+
NSLog(@"Firebase: RunOnAppDelegateClasses - no delegate classes seen yet. Block will be queued for future delegates.");
184183
}
185184

186185
// Always try to queue the block for any future new delegate classes.
187186
// This block will be executed by Firebase_setDelegate if a new delegate class is set.
188187
if (g_pending_block_count < MAX_PENDING_APP_DELEGATE_BLOCKS) {
189188
g_pending_app_delegate_blocks[g_pending_block_count] = [block copy];
190189
g_pending_block_count++;
191-
NSLog(@"Firebase: RunOnAppDelegate - added block to pending list (total pending: %d). This block will run on future new delegate classes.", g_pending_block_count);
190+
NSLog(@"Firebase: RunOnAppDelegateClasses - added block to pending list (total pending: %d). This block will run on future new delegate classes.", g_pending_block_count);
192191
} else {
193-
NSLog(@"Firebase Error: RunOnAppDelegate - pending block queue is full (max %d). Cannot add new block for future execution. Discarding block.", MAX_PENDING_APP_DELEGATE_BLOCKS);
192+
NSLog(@"Firebase Error: RunOnAppDelegateClasses - pending block queue is full (max %d). Cannot add new block for future execution. Discarding block.", MAX_PENDING_APP_DELEGATE_BLOCKS);
194193
// Block is discarded for future execution.
195194
}
196195
}
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ @implementation UIApplication (FIRFCM)
870870
+ (void)load {
871871
// C++ constructors may not be called yet so call NSLog rather than LogInfo.
872872
NSLog(@"FCM: Loading UIApplication FIRFCM category");
873-
::firebase::util::RunOnAppDelegate(^(Class clazz) { // Renamed here
873+
::firebase::util::RunOnAppDelegateClasses(^(Class clazz) {
874874
FirebaseMessagingHookAppDelegate(clazz);
875875
});
876876
}

0 commit comments

Comments
 (0)