From 3e73d79a65cbe4c8af59ad28efc74b37faf40b43 Mon Sep 17 00:00:00 2001 From: Charlotte Liang Date: Wed, 9 Feb 2022 12:31:04 -0800 Subject: [PATCH 1/2] add GULMulticastUserNotificationCenterDelegate --- .../Sources/GULMulticastAppDelegate.m | 33 +++- ...LMulticastUserNotificationCenterDelegate.m | 182 ++++++++++++++++++ ...LMulticastUserNotificationCenterDelegate.h | 37 ++++ 3 files changed, 250 insertions(+), 2 deletions(-) create mode 100644 GoogleUtilitiesMulticastAppDelegate/Sources/GULMulticastUserNotificationCenterDelegate.m create mode 100644 GoogleUtilitiesMulticastAppDelegate/Sources/Public/GoogleUtilities/GULMulticastUserNotificationCenterDelegate.h diff --git a/GoogleUtilitiesMulticastAppDelegate/Sources/GULMulticastAppDelegate.m b/GoogleUtilitiesMulticastAppDelegate/Sources/GULMulticastAppDelegate.m index 08208e15..85b62516 100644 --- a/GoogleUtilitiesMulticastAppDelegate/Sources/GULMulticastAppDelegate.m +++ b/GoogleUtilitiesMulticastAppDelegate/Sources/GULMulticastAppDelegate.m @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#import "GoogleUtilitiesMulticastAppDelegate/Sources/Public/GoogleUtilities/GULMulticastAppDelegate.h" +#import @interface GULMulticastAppDelegate () { NSMutableArray *_interceptors; @@ -126,7 +126,16 @@ - (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { } #endif // !TARGET_OS_WATCH -#if TARGET_OS_IOS || TARGET_OS_TV +#if TARGET_OS_WATCH + +- (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { + for (id interceptor in _interceptors) { + if ([interceptor respondsToSelector:@selector(didFailToRegisterForRemoteNotificationsWithError:)]) { + [interceptor didFailToRegisterForRemoteNotificationsWithError:error]; + } + } +} +#elif TARGET_OS_IOS || TARGET_OS_TV - (void)application:(GULApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { for (id interceptor in _interceptors) { @@ -151,4 +160,24 @@ - (void)application:(GULApplication *)application } #endif +#pragma mark - UNUserNotificationCenterDelegate + +//-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler API_AVAILABLE(ios(10.0)){ +// for (id interceptor in _interceptors) { +// if ([interceptor respondsToSelector:@selector +// (userNotificationCenter:willPresentNotification:withCompletionHandler:)]) { +// [interceptor userNotificationCenter:center willPresentNotification:notification withCompletionHandler:completionHandler]; +// } +// } +//} +// +//-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler API_AVAILABLE(ios(10.0)){ +// for (id interceptor in _interceptors) { +// if ([interceptor respondsToSelector:@selector +// (userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:)]) { +// [interceptor userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler]; +// } +// } +//} + @end diff --git a/GoogleUtilitiesMulticastAppDelegate/Sources/GULMulticastUserNotificationCenterDelegate.m b/GoogleUtilitiesMulticastAppDelegate/Sources/GULMulticastUserNotificationCenterDelegate.m new file mode 100644 index 00000000..dd1e4fa0 --- /dev/null +++ b/GoogleUtilitiesMulticastAppDelegate/Sources/GULMulticastUserNotificationCenterDelegate.m @@ -0,0 +1,182 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import + +API_AVAILABLE(ios(10.0)) +@interface GULMulticastUserNotificationCenterDelegate () { + NSMutableArray *_interceptors; + id _defaultAppDelegate; +} +@end + +@implementation GULMulticastUserNotificationCenterDelegate + +- (instancetype)initWithAppDelegate:(id)delegate API_AVAILABLE(ios(10.0)){ + self = [super init]; + if (self) { + _interceptors = [NSMutableArray arrayWithObject:delegate]; + [UNUserNotificationCenter currentNotificationCenter].delegate = delegate; + _defaultAppDelegate = delegate; + } + return self; +} + ++ (id)multicastDelegate { + if (@available(iOS 10.0, *)) { + id appDelegate = [UIApplication sharedApplication].delegate; + + if (!appDelegate) { + return nil; + } + if ([appDelegate conformsToProtocol:@protocol(GULMulticastAppDelegateProtocol)]) { + id multicastAppDelegate = + (id)appDelegate; + return multicastAppDelegate; + } + if ([appDelegate respondsToSelector:@selector(getMulticastDelegate)]) { + id multicastDelegate = + [appDelegate performSelector:@selector(getMulticastDelegate)]; + CFRetain((__bridge CFTypeRef)(multicastDelegate)); + return multicastDelegate; + } + } else { + // Fallback on earlier versions + } + return nil; +} + +- (id)getMulticastDelegate { + return self; +} + +- (void)addInterceptorWithInterceptor:(id)interceptor API_AVAILABLE(ios(10.0)){ + [_interceptors addObject:interceptor]; +} + +- (void)removeInterceptorWithInterceptor:(id)interceptor API_AVAILABLE(ios(10.0)){ + [_interceptors removeObject:interceptor]; +} + +- (BOOL)respondsToSelector:(SEL)aSelector { + if ([[self class] instancesRespondToSelector:aSelector]) { + return YES; + } + for (id interceptor in _interceptors) { + if (interceptor && [interceptor respondsToSelector:aSelector]) { + return YES; + } + } + return NO; +} + +- (void)setDefaultAppDelegate:(id)defaultAppDelegate API_AVAILABLE(ios(10.0)){ + [_interceptors addObject:defaultAppDelegate]; + _defaultAppDelegate = defaultAppDelegate; +} + +- (id)forwardingTargetForSelector:(SEL)aSelector { + return _defaultAppDelegate; +} + +#if !TARGET_OS_WATCH +#pragma mark - Open URL +- (BOOL)application:(GULApplication *)app + openURL:(NSURL *)url + options:(NSDictionary *)options { + BOOL result = NO; + for (id interceptor in _interceptors) { + result = result || [interceptor application:app openURL:url options:options]; + } + return result; +} + +#pragma mark - APNS methods +- (void)application:(GULApplication *)application + didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { + for (id interceptor in _interceptors) { + if ([interceptor respondsToSelector:@selector(application: + didRegisterForRemoteNotificationsWithDeviceToken:)]) { + [interceptor application:application + didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; + } + } +} + +#else // !TARGET_OS_WATCH +- (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { + for (id interceptor in _interceptors) { + if ([interceptor + respondsToSelector:@selector(didRegisterForRemoteNotificationsWithDeviceToken)]) { + [interceptor didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; + } + } +} +#endif // !TARGET_OS_WATCH + +#if TARGET_OS_WATCH + +- (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { + for (id interceptor in _interceptors) { + if ([interceptor respondsToSelector:@selector(didFailToRegisterForRemoteNotificationsWithError:)]) { + [interceptor didFailToRegisterForRemoteNotificationsWithError:error]; + } + } +} +#elif TARGET_OS_IOS || TARGET_OS_TV +- (void)application:(GULApplication *)application + didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { + for (id interceptor in _interceptors) { + if ([interceptor respondsToSelector:@selector(application: + didFailToRegisterForRemoteNotificationsWithError:)]) { + [interceptor application:application didFailToRegisterForRemoteNotificationsWithError:error]; + } + } +} + +- (void)application:(GULApplication *)application + didReceiveRemoteNotification:(NSDictionary *)userInfo + fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { + for (id interceptor in _interceptors) { + if ([interceptor respondsToSelector:@selector + (application:didReceiveRemoteNotification:fetchCompletionHandler:)]) { + [interceptor application:application + didReceiveRemoteNotification:userInfo + fetchCompletionHandler:completionHandler]; + } + } +} +#endif + +#pragma mark - UNUserNotificationCenterDelegate + +-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler API_AVAILABLE(ios(10.0)){ + for (id interceptor in _interceptors) { + if ([interceptor respondsToSelector:@selector + (userNotificationCenter:willPresentNotification:withCompletionHandler:)]) { + [interceptor userNotificationCenter:center willPresentNotification:notification withCompletionHandler:completionHandler]; + } + } +} + +-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler API_AVAILABLE(ios(10.0)){ + for (id interceptor in _interceptors) { + if ([interceptor respondsToSelector:@selector + (userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:)]) { + [interceptor userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler]; + } + } +} + +@end diff --git a/GoogleUtilitiesMulticastAppDelegate/Sources/Public/GoogleUtilities/GULMulticastUserNotificationCenterDelegate.h b/GoogleUtilitiesMulticastAppDelegate/Sources/Public/GoogleUtilities/GULMulticastUserNotificationCenterDelegate.h new file mode 100644 index 00000000..3e8171ce --- /dev/null +++ b/GoogleUtilitiesMulticastAppDelegate/Sources/Public/GoogleUtilities/GULMulticastUserNotificationCenterDelegate.h @@ -0,0 +1,37 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 || \ + __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_14 || __TV_OS_VERSION_MAX_ALLOWED >= __TV_10_0 || \ + __WATCH_OS_VERSION_MAX_ALLOWED >= __WATCHOS_3_0 || TARGET_OS_MACCATALYST +#import +#endif +#import + +NS_ASSUME_NONNULL_BEGIN + +API_AVAILABLE(ios(10.0)) +@interface GULMulticastUserNotificationCenterDelegate : NSObject + +@property(nonatomic, copy) id defaultAppDelegate; + +-(instancetype)initWithAppDelegate:(id)delegate; + +-(void)addInterceptorWithInterceptor:(id)delegate; + ++ (id)multicastDelegate; +@end + +NS_ASSUME_NONNULL_END From 68e2244a422a19308b85b92320f45f3bd92973c0 Mon Sep 17 00:00:00 2001 From: Charlotte Liang Date: Wed, 16 Feb 2022 14:04:31 -0800 Subject: [PATCH 2/2] add GULMulticastUserNotificationCenterDelegate --- GoogleUtilitiesMulticastAppDelegate.podspec | 6 +- .../Sources/GULMulticastAppDelegate.m | 33 ++--- ...LMulticastUserNotificationCenterDelegate.m | 129 +++++------------- .../GoogleUtilities/GULMulticastAppDelegate.h | 4 +- ...LMulticastUserNotificationCenterDelegate.h | 15 +- 5 files changed, 61 insertions(+), 126 deletions(-) diff --git a/GoogleUtilitiesMulticastAppDelegate.podspec b/GoogleUtilitiesMulticastAppDelegate.podspec index 22245a42..d25605eb 100644 --- a/GoogleUtilitiesMulticastAppDelegate.podspec +++ b/GoogleUtilitiesMulticastAppDelegate.podspec @@ -22,9 +22,9 @@ Pod::Spec.new do |s| watchos_deployment_target = '6.0' s.ios.deployment_target = ios_deployment_target - # s.osx.deployment_target = osx_deployment_target - # s.tvos.deployment_target = tvos_deployment_target - # s.watchos.deployment_target = watchos_deployment_target + s.osx.deployment_target = osx_deployment_target + s.tvos.deployment_target = tvos_deployment_target + s.watchos.deployment_target = watchos_deployment_target s.cocoapods_version = '>= 1.4.0' s.prefix_header_file = false diff --git a/GoogleUtilitiesMulticastAppDelegate/Sources/GULMulticastAppDelegate.m b/GoogleUtilitiesMulticastAppDelegate/Sources/GULMulticastAppDelegate.m index 85b62516..9e2ff09a 100644 --- a/GoogleUtilitiesMulticastAppDelegate/Sources/GULMulticastAppDelegate.m +++ b/GoogleUtilitiesMulticastAppDelegate/Sources/GULMulticastAppDelegate.m @@ -13,6 +13,7 @@ // limitations under the License. #import +//#import @interface GULMulticastAppDelegate () { NSMutableArray *_interceptors; @@ -40,7 +41,7 @@ - (instancetype)initWithAppDelegate:(id)delegate { } + (id)multicastDelegate { - id appDelegate = [UIApplication sharedApplication].delegate; + id appDelegate = [GULAppDelegateSwizzler sharedApplication].delegate; if (!appDelegate) { return nil; } @@ -64,6 +65,9 @@ - (instancetype)initWithAppDelegate:(id)delegate { - (void)addInterceptorWithInterceptor:(id)interceptor { [_interceptors addObject:interceptor]; + if (!_defaultAppDelegate) { + _defaultAppDelegate = interceptor; + } } - (void)removeInterceptorWithInterceptor:(id)interceptor { @@ -71,6 +75,9 @@ - (void)removeInterceptorWithInterceptor:(id)interceptor } - (BOOL)respondsToSelector:(SEL)aSelector { + if (_defaultAppDelegate && [_defaultAppDelegate respondsToSelector:aSelector]) { + return YES; + } if ([[self class] instancesRespondToSelector:aSelector]) { return YES; } @@ -79,6 +86,7 @@ - (BOOL)respondsToSelector:(SEL)aSelector { return YES; } } + return NO; } @@ -130,7 +138,8 @@ - (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { - (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { for (id interceptor in _interceptors) { - if ([interceptor respondsToSelector:@selector(didFailToRegisterForRemoteNotificationsWithError:)]) { + if ([interceptor + respondsToSelector:@selector(didFailToRegisterForRemoteNotificationsWithError:)]) { [interceptor didFailToRegisterForRemoteNotificationsWithError:error]; } } @@ -160,24 +169,4 @@ - (void)application:(GULApplication *)application } #endif -#pragma mark - UNUserNotificationCenterDelegate - -//-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler API_AVAILABLE(ios(10.0)){ -// for (id interceptor in _interceptors) { -// if ([interceptor respondsToSelector:@selector -// (userNotificationCenter:willPresentNotification:withCompletionHandler:)]) { -// [interceptor userNotificationCenter:center willPresentNotification:notification withCompletionHandler:completionHandler]; -// } -// } -//} -// -//-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler API_AVAILABLE(ios(10.0)){ -// for (id interceptor in _interceptors) { -// if ([interceptor respondsToSelector:@selector -// (userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:)]) { -// [interceptor userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler]; -// } -// } -//} - @end diff --git a/GoogleUtilitiesMulticastAppDelegate/Sources/GULMulticastUserNotificationCenterDelegate.m b/GoogleUtilitiesMulticastAppDelegate/Sources/GULMulticastUserNotificationCenterDelegate.m index dd1e4fa0..45be3a6f 100644 --- a/GoogleUtilitiesMulticastAppDelegate/Sources/GULMulticastUserNotificationCenterDelegate.m +++ b/GoogleUtilitiesMulticastAppDelegate/Sources/GULMulticastUserNotificationCenterDelegate.m @@ -17,37 +17,36 @@ API_AVAILABLE(ios(10.0)) @interface GULMulticastUserNotificationCenterDelegate () { NSMutableArray *_interceptors; - id _defaultAppDelegate; + id _defaultAppDelegate; } @end @implementation GULMulticastUserNotificationCenterDelegate -- (instancetype)initWithAppDelegate:(id)delegate API_AVAILABLE(ios(10.0)){ +- (instancetype)init API_AVAILABLE(ios(10.0)) { self = [super init]; if (self) { - _interceptors = [NSMutableArray arrayWithObject:delegate]; - [UNUserNotificationCenter currentNotificationCenter].delegate = delegate; - _defaultAppDelegate = delegate; + _interceptors = [NSMutableArray array]; } return self; } -+ (id)multicastDelegate { ++ (id)multicastDelegate { if (@available(iOS 10.0, *)) { - id appDelegate = [UIApplication sharedApplication].delegate; + id appDelegate = + [UNUserNotificationCenter currentNotificationCenter].delegate; if (!appDelegate) { return nil; } - if ([appDelegate conformsToProtocol:@protocol(GULMulticastAppDelegateProtocol)]) { - id multicastAppDelegate = - (id)appDelegate; + if ([appDelegate conformsToProtocol:@protocol(GULMulticastNotificationProtocol)]) { + id multicastAppDelegate = + (id)appDelegate; return multicastAppDelegate; } if ([appDelegate respondsToSelector:@selector(getMulticastDelegate)]) { - id multicastDelegate = - [appDelegate performSelector:@selector(getMulticastDelegate)]; + id multicastDelegate = + [appDelegate performSelector:@selector(getMulticastDelegate)]; CFRetain((__bridge CFTypeRef)(multicastDelegate)); return multicastDelegate; } @@ -61,11 +60,13 @@ - (instancetype)initWithAppDelegate:(id)interceptor API_AVAILABLE(ios(10.0)){ +- (void)addInterceptorWithInterceptor:(id)interceptor + API_AVAILABLE(ios(10.0)) { [_interceptors addObject:interceptor]; } -- (void)removeInterceptorWithInterceptor:(id)interceptor API_AVAILABLE(ios(10.0)){ +- (void)removeInterceptorWithInterceptor:(id)interceptor + API_AVAILABLE(ios(10.0)) { [_interceptors removeObject:interceptor]; } @@ -73,7 +74,7 @@ - (BOOL)respondsToSelector:(SEL)aSelector { if ([[self class] instancesRespondToSelector:aSelector]) { return YES; } - for (id interceptor in _interceptors) { + for (id interceptor in _interceptors) { if (interceptor && [interceptor respondsToSelector:aSelector]) { return YES; } @@ -81,7 +82,8 @@ - (BOOL)respondsToSelector:(SEL)aSelector { return NO; } -- (void)setDefaultAppDelegate:(id)defaultAppDelegate API_AVAILABLE(ios(10.0)){ +- (void)setDefaultAppDelegate:(id)defaultAppDelegate + API_AVAILABLE(ios(10.0)) { [_interceptors addObject:defaultAppDelegate]; _defaultAppDelegate = defaultAppDelegate; } @@ -90,91 +92,32 @@ - (id)forwardingTargetForSelector:(SEL)aSelector { return _defaultAppDelegate; } -#if !TARGET_OS_WATCH -#pragma mark - Open URL -- (BOOL)application:(GULApplication *)app - openURL:(NSURL *)url - options:(NSDictionary *)options { - BOOL result = NO; - for (id interceptor in _interceptors) { - result = result || [interceptor application:app openURL:url options:options]; - } - return result; -} - -#pragma mark - APNS methods -- (void)application:(GULApplication *)application - didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { - for (id interceptor in _interceptors) { - if ([interceptor respondsToSelector:@selector(application: - didRegisterForRemoteNotificationsWithDeviceToken:)]) { - [interceptor application:application - didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; - } - } -} - -#else // !TARGET_OS_WATCH -- (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { - for (id interceptor in _interceptors) { - if ([interceptor - respondsToSelector:@selector(didRegisterForRemoteNotificationsWithDeviceToken)]) { - [interceptor didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; - } - } -} -#endif // !TARGET_OS_WATCH - -#if TARGET_OS_WATCH - -- (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { - for (id interceptor in _interceptors) { - if ([interceptor respondsToSelector:@selector(didFailToRegisterForRemoteNotificationsWithError:)]) { - [interceptor didFailToRegisterForRemoteNotificationsWithError:error]; - } - } -} -#elif TARGET_OS_IOS || TARGET_OS_TV -- (void)application:(GULApplication *)application - didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { - for (id interceptor in _interceptors) { - if ([interceptor respondsToSelector:@selector(application: - didFailToRegisterForRemoteNotificationsWithError:)]) { - [interceptor application:application didFailToRegisterForRemoteNotificationsWithError:error]; - } - } -} - -- (void)application:(GULApplication *)application - didReceiveRemoteNotification:(NSDictionary *)userInfo - fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { - for (id interceptor in _interceptors) { - if ([interceptor respondsToSelector:@selector - (application:didReceiveRemoteNotification:fetchCompletionHandler:)]) { - [interceptor application:application - didReceiveRemoteNotification:userInfo - fetchCompletionHandler:completionHandler]; - } - } -} -#endif - #pragma mark - UNUserNotificationCenterDelegate --(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler API_AVAILABLE(ios(10.0)){ +- (void)userNotificationCenter:(UNUserNotificationCenter *)center + willPresentNotification:(UNNotification *)notification + withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler + API_AVAILABLE(ios(10.0)) { for (id interceptor in _interceptors) { - if ([interceptor respondsToSelector:@selector - (userNotificationCenter:willPresentNotification:withCompletionHandler:)]) { - [interceptor userNotificationCenter:center willPresentNotification:notification withCompletionHandler:completionHandler]; + if ([interceptor respondsToSelector:@selector(userNotificationCenter: + willPresentNotification:withCompletionHandler:)]) { + [interceptor userNotificationCenter:center + willPresentNotification:notification + withCompletionHandler:completionHandler]; } } } --(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler API_AVAILABLE(ios(10.0)){ +- (void)userNotificationCenter:(UNUserNotificationCenter *)center + didReceiveNotificationResponse:(UNNotificationResponse *)response + withCompletionHandler:(void (^)(void))completionHandler API_AVAILABLE(ios(10.0)) { for (id interceptor in _interceptors) { - if ([interceptor respondsToSelector:@selector - (userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:)]) { - [interceptor userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler]; + if ([interceptor + respondsToSelector:@selector(userNotificationCenter: + didReceiveNotificationResponse:withCompletionHandler:)]) { + [interceptor userNotificationCenter:center + didReceiveNotificationResponse:response + withCompletionHandler:completionHandler]; } } } diff --git a/GoogleUtilitiesMulticastAppDelegate/Sources/Public/GoogleUtilities/GULMulticastAppDelegate.h b/GoogleUtilitiesMulticastAppDelegate/Sources/Public/GoogleUtilities/GULMulticastAppDelegate.h index e59e8a40..df56e93c 100644 --- a/GoogleUtilitiesMulticastAppDelegate/Sources/Public/GoogleUtilities/GULMulticastAppDelegate.h +++ b/GoogleUtilitiesMulticastAppDelegate/Sources/Public/GoogleUtilities/GULMulticastAppDelegate.h @@ -14,7 +14,7 @@ #import -#import +#import NS_ASSUME_NONNULL_BEGIN @@ -32,8 +32,6 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithAppDelegate:(id)delegate; -- (void)addInterceptorWithInterceptor:(id)delegate; - + (id)multicastDelegate; @end diff --git a/GoogleUtilitiesMulticastAppDelegate/Sources/Public/GoogleUtilities/GULMulticastUserNotificationCenterDelegate.h b/GoogleUtilitiesMulticastAppDelegate/Sources/Public/GoogleUtilities/GULMulticastUserNotificationCenterDelegate.h index 3e8171ce..0c9cc0a6 100644 --- a/GoogleUtilitiesMulticastAppDelegate/Sources/Public/GoogleUtilities/GULMulticastUserNotificationCenterDelegate.h +++ b/GoogleUtilitiesMulticastAppDelegate/Sources/Public/GoogleUtilities/GULMulticastUserNotificationCenterDelegate.h @@ -23,15 +23,20 @@ NS_ASSUME_NONNULL_BEGIN API_AVAILABLE(ios(10.0)) -@interface GULMulticastUserNotificationCenterDelegate : NSObject +@protocol GULMulticastNotificationProtocol -@property(nonatomic, copy) id defaultAppDelegate; +- (void)addInterceptorWithInterceptor:(id)interceptor; --(instancetype)initWithAppDelegate:(id)delegate; +- (void)removeInterceptorWithInterceptor:(id)interceptor; --(void)addInterceptorWithInterceptor:(id)delegate; +@end + +API_AVAILABLE(ios(10.0)) +@interface GULMulticastUserNotificationCenterDelegate : NSObject + +@property(nonatomic, copy) id defaultAppDelegate; -+ (id)multicastDelegate; ++ (id)multicastDelegate; @end NS_ASSUME_NONNULL_END