Skip to content

Commit

Permalink
Improve FirebaseMessaging remote notification proxy source code (#13818)
Browse files Browse the repository at this point in the history
  • Loading branch information
MojtabaHs authored Oct 5, 2024
1 parent 236022e commit 4da2c15
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions FirebaseMessaging/Sources/FIRMessagingRemoteNotificationsProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,10 @@ - (void)swizzleSelector:(SEL)originalSelector
IMP originalMethodImplementation =
method_setImplementation(originalMethod, swizzledImplementation);

IMP nonexistantMethodImplementation = [self nonExistantMethodImplementationForClass:klass];
IMP nonexistentMethodImplementation = [self nonExistentMethodImplementationForClass:klass];

if (originalMethodImplementation &&
originalMethodImplementation != nonexistantMethodImplementation &&
originalMethodImplementation != nonexistentMethodImplementation &&
originalMethodImplementation != swizzledImplementation) {
[self saveOriginalImplementation:originalMethodImplementation forSelector:originalSelector];
}
Expand Down Expand Up @@ -344,8 +344,8 @@ - (void)unswizzleSelector:(SEL)selector inClass:(Class)klass {
// behavior as if the method was not implemented.
// See: http://stackoverflow.com/a/8276527/9849

IMP nonExistantMethodImplementation = [self nonExistantMethodImplementationForClass:klass];
method_setImplementation(swizzledMethod, nonExistantMethodImplementation);
IMP nonExistentMethodImplementation = [self nonExistentMethodImplementationForClass:klass];
method_setImplementation(swizzledMethod, nonExistentMethodImplementation);
}
}

Expand All @@ -354,10 +354,10 @@ - (void)unswizzleSelector:(SEL)selector inClass:(Class)klass {
// This is useful to generate from a stable, "known missing" selector, as the IMP can be compared
// in case we are setting an implementation for a class that was previously "unswizzled" into a
// non-existent implementation.
- (IMP)nonExistantMethodImplementationForClass:(Class)klass {
SEL nonExistantSelector = NSSelectorFromString(@"aNonExistantMethod");
IMP nonExistantMethodImplementation = class_getMethodImplementation(klass, nonExistantSelector);
return nonExistantMethodImplementation;
- (IMP)nonExistentMethodImplementationForClass:(Class)klass {
SEL nonExistentSelector = NSSelectorFromString(@"aNonExistentMethod");
IMP nonExistentMethodImplementation = class_getMethodImplementation(klass, nonExistentSelector);
return nonExistentMethodImplementation;
}

// A safe, non-leaky way return a property object by its name
Expand Down

0 comments on commit 4da2c15

Please sign in to comment.