@@ -93,9 +93,9 @@ - (void)swizzleMethodsIfPossible {
9393 Class notificationCenterClass = NSClassFromString (@" UNUserNotificationCenter" );
9494 if (notificationCenterClass) {
9595 // We are linked against iOS 10 SDK or above
96- id notificationCenter = getNamedPropertyFromObject (notificationCenterClass,
97- @" currentNotificationCenter" ,
98- notificationCenterClass);
96+ id notificationCenter = FIRMessagingPropertyNameFromObject (notificationCenterClass,
97+ @" currentNotificationCenter" ,
98+ notificationCenterClass);
9999 if (notificationCenter) {
100100 [self listenForDelegateChangesInUserNotificationCenter: notificationCenter];
101101 }
@@ -125,7 +125,7 @@ - (void)listenForDelegateChangesInUserNotificationCenter:(id)notificationCenter
125125 if (![notificationCenter isKindOfClass: notificationCenterClass]) {
126126 return ;
127127 }
128- id delegate = getNamedPropertyFromObject (notificationCenter, @" delegate" , nil );
128+ id delegate = FIRMessagingPropertyNameFromObject (notificationCenter, @" delegate" , nil );
129129 Protocol *delegateProtocol = NSProtocolFromString (@" UNUserNotificationCenterDelegate" );
130130 if ([delegate conformsToProtocol: delegateProtocol]) {
131131 // Swizzle this object now, if available
@@ -156,15 +156,15 @@ - (void)swizzleUserNotificationCenterDelegate:(id _Nonnull)delegate {
156156 if ([delegate respondsToSelector: willPresentNotificationSelector]) {
157157 [self swizzleSelector: willPresentNotificationSelector
158158 inClass: [delegate class ]
159- withImplementation: (IMP )FCM_swizzle_willPresentNotificationWithHandler
159+ withImplementation: (IMP )FCMSwizzleWillPresentNotificationWithHandler
160160 inProtocol: userNotificationCenterProtocol];
161161 }
162162 SEL didReceiveNotificationResponseSelector =
163163 NSSelectorFromString (kUserNotificationDidReceiveResponseSelectorString );
164164 if ([delegate respondsToSelector: didReceiveNotificationResponseSelector]) {
165165 [self swizzleSelector: didReceiveNotificationResponseSelector
166166 inClass: [delegate class ]
167- withImplementation: (IMP )FCM_swizzle_didReceiveNotificationResponseWithHandler
167+ withImplementation: (IMP )FCMSwizzleDidReceiveNotificationResponseWithHandler
168168 inProtocol: userNotificationCenterProtocol];
169169 }
170170 self.currentUserNotificationCenterDelegate = delegate;
@@ -263,13 +263,13 @@ - (void)saveOriginalImplementation:(IMP)imp forSelector:(SEL)selector {
263263
264264- (IMP )originalImplementationForSelector : (SEL )selector {
265265 NSString *selectorString = NSStringFromSelector (selector);
266- NSValue *implementation_value = self.originalAppDelegateImps [selectorString];
267- if (!implementation_value ) {
266+ NSValue *implementationValue = self.originalAppDelegateImps [selectorString];
267+ if (!implementationValue ) {
268268 return nil ;
269269 }
270270
271271 IMP imp;
272- [implementation_value getValue: &imp];
272+ [implementationValue getValue: &imp];
273273 return imp;
274274}
275275
@@ -300,27 +300,27 @@ - (void)swizzleSelector:(SEL)originalSelector
300300 // This class implements this method, so replace the original implementation
301301 // with our new implementation and save the old implementation.
302302
303- IMP __original_method_implementation =
303+ IMP originalMethodImplementation =
304304 method_setImplementation (originalMethod, swizzledImplementation);
305305
306- IMP __nonexistant_method_implementation = [self nonExistantMethodImplementationForClass: klass];
306+ IMP nonexistantMethodImplementation = [self nonExistantMethodImplementationForClass: klass];
307307
308- if (__original_method_implementation &&
309- __original_method_implementation != __nonexistant_method_implementation &&
310- __original_method_implementation != swizzledImplementation) {
311- [self saveOriginalImplementation: __original_method_implementation
308+ if (originalMethodImplementation &&
309+ originalMethodImplementation != nonexistantMethodImplementation &&
310+ originalMethodImplementation != swizzledImplementation) {
311+ [self saveOriginalImplementation: originalMethodImplementation
312312 forSelector: originalSelector];
313313 }
314314 } else {
315315 // The class doesn't have this method, so add our swizzled implementation as the
316316 // original implementation of the original method.
317- struct objc_method_description method_description =
317+ struct objc_method_description methodDescription =
318318 protocol_getMethodDescription (protocol, originalSelector, NO , YES );
319319
320320 BOOL methodAdded = class_addMethod (klass,
321321 originalSelector,
322322 swizzledImplementation,
323- method_description .types );
323+ methodDescription .types );
324324 if (!methodAdded) {
325325 FIRMessagingLoggerError (kFIRMessagingMessageCodeRemoteNotificationsProxyMethodNotAdded ,
326326 @" Could not add method for %@ to class %@ " ,
@@ -339,10 +339,10 @@ - (void)unswizzleSelector:(SEL)selector inClass:(Class)klass {
339339 return ;
340340 }
341341
342- IMP original_imp = [self originalImplementationForSelector: selector];
343- if (original_imp ) {
342+ IMP originalImp = [self originalImplementationForSelector: selector];
343+ if (originalImp ) {
344344 // Restore the original implementation as the current implementation
345- method_setImplementation (swizzledMethod, original_imp );
345+ method_setImplementation (swizzledMethod, originalImp );
346346 [self removeImplementationForSelector: selector];
347347 } else {
348348 // This class originally did not have an implementation for this selector.
@@ -369,7 +369,7 @@ - (IMP)nonExistantMethodImplementationForClass:(Class)klass {
369369}
370370
371371// A safe, non-leaky way return a property object by its name
372- id getNamedPropertyFromObject (id object, NSString *propertyName, Class klass) {
372+ id FIRMessagingPropertyNameFromObject (id object, NSString *propertyName, Class klass) {
373373 SEL selector = NSSelectorFromString (propertyName);
374374 if (![object respondsToSelector: selector]) {
375375 return nil ;
@@ -433,16 +433,16 @@ - (void)application:(GULApplication *)application
433433 * In order to make FCM SDK compile and compatible with iOS SDKs before iOS 10, hide the
434434 * parameter types from the swizzling implementation.
435435 */
436- void FCM_swizzle_willPresentNotificationWithHandler (
437- id self, SEL _cmd , id center, id notification, void (^handler)(NSUInteger )) {
436+ static void FCMSwizzleWillPresentNotificationWithHandler (
437+ id self, SEL cmd , id center, id notification, void (^handler)(NSUInteger )) {
438438
439439 FIRMessagingRemoteNotificationsProxy *proxy = [FIRMessagingRemoteNotificationsProxy sharedProxy ];
440- IMP original_imp = [proxy originalImplementationForSelector: _cmd ];
440+ IMP originalImp = [proxy originalImplementationForSelector: cmd ];
441441
442442 void (^callOriginalMethodIfAvailable)(void ) = ^{
443- if (original_imp ) {
444- ((void (*)(id , SEL , id , id , void (^)(NSUInteger )))original_imp )(
445- self, _cmd , center, notification, handler);
443+ if (originalImp ) {
444+ ((void (*)(id , SEL , id , id , void (^)(NSUInteger )))originalImp )(
445+ self, cmd , center, notification, handler);
446446 }
447447 return ;
448448 };
@@ -476,7 +476,7 @@ void FCM_swizzle_willPresentNotificationWithHandler(
476476 }
477477
478478 // Attempt to access the user info
479- id notificationUserInfo = userInfoFromNotification (notification);
479+ id notificationUserInfo = FIRMessagingUserInfoFromNotification (notification);
480480
481481 if (!notificationUserInfo) {
482482 // Could not access notification.request.content.userInfo.
@@ -498,16 +498,16 @@ void FCM_swizzle_willPresentNotificationWithHandler(
498498 * In order to make FCM SDK compile and compatible with iOS SDKs before iOS 10, hide the
499499 * parameter types from the swizzling implementation.
500500 */
501- void FCM_swizzle_didReceiveNotificationResponseWithHandler (
502- id self, SEL _cmd , id center, id response, void (^handler)(void )) {
501+ static void FCMSwizzleDidReceiveNotificationResponseWithHandler (
502+ id self, SEL cmd , id center, id response, void (^handler)(void )) {
503503
504504 FIRMessagingRemoteNotificationsProxy *proxy = [FIRMessagingRemoteNotificationsProxy sharedProxy ];
505- IMP original_imp = [proxy originalImplementationForSelector: _cmd ];
505+ IMP originalImp = [proxy originalImplementationForSelector: cmd ];
506506
507507 void (^callOriginalMethodIfAvailable)(void ) = ^{
508- if (original_imp ) {
509- ((void (*)(id , SEL , id , id , void (^)(void )))original_imp )(
510- self, _cmd , center, response, handler);
508+ if (originalImp ) {
509+ ((void (*)(id , SEL , id , id , void (^)(void )))originalImp )(
510+ self, cmd , center, response, handler);
511511 }
512512 return ;
513513 };
@@ -543,11 +543,11 @@ void FCM_swizzle_didReceiveNotificationResponseWithHandler(
543543 return ;
544544 }
545545 id notificationClass = NSClassFromString (@" UNNotification" );
546- id notification = getNamedPropertyFromObject (response, @" notification" , notificationClass);
546+ id notification = FIRMessagingPropertyNameFromObject (response, @" notification" , notificationClass);
547547
548548 // With a notification object, use the common code to reach deep into notification
549549 // (notification.request.content.userInfo)
550- id notificationUserInfo = userInfoFromNotification (notification);
550+ id notificationUserInfo = FIRMessagingUserInfoFromNotification (notification);
551551 if (!notificationUserInfo) {
552552 // Could not access notification.request.content.userInfo.
553553 callOriginalMethodIfAvailable ();
@@ -559,7 +559,7 @@ void FCM_swizzle_didReceiveNotificationResponseWithHandler(
559559 callOriginalMethodIfAvailable ();
560560}
561561
562- id userInfoFromNotification (id notification) {
562+ static id FIRMessagingUserInfoFromNotification (id notification) {
563563
564564 // Select the userInfo field from UNNotification.request.content.userInfo.
565565 SEL requestSelector = NSSelectorFromString (@" request" );
@@ -568,7 +568,7 @@ id userInfoFromNotification(id notification) {
568568 return nil ;
569569 }
570570 Class requestClass = NSClassFromString (@" UNNotificationRequest" );
571- id notificationRequest = getNamedPropertyFromObject (notification, @" request" , requestClass);
571+ id notificationRequest = FIRMessagingPropertyNameFromObject (notification, @" request" , requestClass);
572572
573573 SEL notificationContentSelector = NSSelectorFromString (@" content" );
574574 if (!notificationRequest
@@ -577,19 +577,19 @@ id userInfoFromNotification(id notification) {
577577 return nil ;
578578 }
579579 Class contentClass = NSClassFromString (@" UNNotificationContent" );
580- id notificationContent = getNamedPropertyFromObject (notificationRequest,
581- @" content" ,
582- contentClass);
580+ id notificationContent = FIRMessagingPropertyNameFromObject (notificationRequest,
581+ @" content" ,
582+ contentClass);
583583
584584 SEL notificationUserInfoSelector = NSSelectorFromString (@" userInfo" );
585585 if (!notificationContent
586586 || ![notificationContent respondsToSelector: notificationUserInfoSelector]) {
587587 // Cannot access the userInfo property.
588588 return nil ;
589589 }
590- id notificationUserInfo = getNamedPropertyFromObject (notificationContent,
591- @" userInfo" ,
592- [NSDictionary class ]);
590+ id notificationUserInfo = FIRMessagingPropertyNameFromObject (notificationContent,
591+ @" userInfo" ,
592+ [NSDictionary class ]);
593593
594594 if (!notificationUserInfo) {
595595 // This is not the expected notification handler.
0 commit comments