diff options
author | Riz <rsattar@gmail.com> | 2017-05-23 15:16:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-23 15:16:02 -0700 |
commit | f67c074ed154e6ce2cfd949cc797e7cc7b72490f (patch) | |
tree | cdeb0641c01eef3a332e3bf2cf7f3217df680eec | |
parent | faf445535330b7f0fe0330636c5e996005cb5555 (diff) |
Log an error if for some reason we can't add a method to a class (#24)
Maybe it was already swizzled, or some other issue. Either way, it would be good to log this error, as it might help us / developers diagnose an issue.
-rw-r--r-- | Firebase/Messaging/FIRMMessageCode.h | 1 | ||||
-rw-r--r-- | Firebase/Messaging/FIRMessagingRemoteNotificationsProxy.m | 14 |
2 files changed, 11 insertions, 4 deletions
diff --git a/Firebase/Messaging/FIRMMessageCode.h b/Firebase/Messaging/FIRMMessageCode.h index dc381ee..729d415 100644 --- a/Firebase/Messaging/FIRMMessageCode.h +++ b/Firebase/Messaging/FIRMMessageCode.h @@ -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 diff --git a/Firebase/Messaging/FIRMessagingRemoteNotificationsProxy.m b/Firebase/Messaging/FIRMessagingRemoteNotificationsProxy.m index 5432c79..214bd41 100644 --- a/Firebase/Messaging/FIRMessagingRemoteNotificationsProxy.m +++ b/Firebase/Messaging/FIRMessagingRemoteNotificationsProxy.m @@ -368,10 +368,16 @@ static NSString *kUserNotificationWillPresentSelectorString = 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]; } |