Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log an error if for some reason we can't add a method to a class #24

Merged
merged 1 commit into from
May 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Firebase/Messaging/FIRMMessageCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ typedef NS_ENUM(NSInteger, FIRMessagingMessageCode) {
kFIRMessagingMessageCodeRemoteNotificationsProxy000 = 12000, // I-FCM012000
kFIRMessagingMessageCodeRemoteNotificationsProxy001 = 12001, // I-FCM012001
kFIRMessagingMessageCodeRemoteNotificationsProxyAPNSFailed = 12002, // I-FCM012002
kFIRMessagingMessageCodeRemoteNotificationsProxyMethodNotAdded = 12003, // I-FCM012003
// FIRMessagingRmq2PersistentStore.m
kFIRMessagingMessageCodeRmq2PersistentStore000 = 13000, // I-FCM013000
kFIRMessagingMessageCodeRmq2PersistentStore001 = 13001, // I-FCM013001
Expand Down
14 changes: 10 additions & 4 deletions Firebase/Messaging/FIRMessagingRemoteNotificationsProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,16 @@ - (void)swizzleSelector:(SEL)originalSelector
struct objc_method_description method_description =
protocol_getMethodDescription(protocol, originalSelector, NO, YES);

class_addMethod(klass,
originalSelector,
swizzledImplementation,
method_description.types);
BOOL methodAdded = class_addMethod(klass,
originalSelector,
swizzledImplementation,
method_description.types);
if (!methodAdded) {
FIRMessagingLoggerError(kFIRMessagingMessageCodeRemoteNotificationsProxyMethodNotAdded,
@"Could not add method for %@ to class %@",
NSStringFromSelector(originalSelector),
NSStringFromClass(klass));
}
}
[self trackSwizzledSelector:originalSelector ofClass:klass];
}
Expand Down