-
Notifications
You must be signed in to change notification settings - Fork 1.7k
FIRMessagingRemoteNotificationsProxy updated to use GULAppDelegateSwizzler #2683
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
b2eabf2
FIRAuthAppDelegateProxy: implementation updated to use GULAppDelegate…
maksymmalyhin 4ab86de
GULAppDelegateSwizzler - make sure subclass name is unique.
maksymmalyhin 1f1560a
GoogleUtilities: enable code coverage
maksymmalyhin f4a4638
Merge branch 'master'
maksymmalyhin 9fcedce
GULAppDelegateSwizzler: Add support of remote notification methods
maksymmalyhin 27c8b5b
GULAppDelegateSwizzler - tests for remote notification methods
maksymmalyhin dee28d3
Revert "FIRAuthAppDelegateProxy: implementation updated to use GULApp…
maksymmalyhin 5821591
FIRMessaging: prepare to use GULAppDelegateSwizzler [WIP]
maksymmalyhin 908b6ea
FIRMessagingRemoteNotificationsProxy - use GULAppDelegateSwizzler [WIP]
maksymmalyhin 9e377d2
FIRMessagingRemoteNotificationsProxy - AppDelegate proxy - test only …
maksymmalyhin 7861cde
FIRMessagingRemoteNotificationsProxy test only public API with no imp…
maksymmalyhin b7703ac
Cleanup
maksymmalyhin ad1da54
Cleanup
maksymmalyhin 2bdf353
Merge branch 'master'
maksymmalyhin 8eafece
Merge branch 'mm/messaging-tests'
maksymmalyhin e5d2ce8
Merge branch 'master'
maksymmalyhin 86ff257
Cocoapods 1.6.1: Podfile supports only single post_install hook. It i…
maksymmalyhin 79b7613
FIRMessagingRemoteNotificationsProxyTest: [GULAppDelegateSwizzler res…
maksymmalyhin 98ffccb
FIRMessagingRemoteNotificationsProxy: app delegate missing methods te…
maksymmalyhin cd44395
GULAppDelegateSwizzler: don't swizzle invalid application delegate
maksymmalyhin 3df4140
Cleanup
maksymmalyhin dcd0e10
Run ./scripts/check.sh
maksymmalyhin 18381dd
Merge branch 'master'
maksymmalyhin dae75d9
GoogleUtilities/GULAppDelegateSwizzler - tvOS support
maksymmalyhin 6dee8d3
style.sh generated changes
maksymmalyhin 2726e7c
FirebaseMessaging - missing dependencies added
maksymmalyhin 63fd1f5
FCM data channel messages - pass data to [FIRMessaging appDidReceiveM…
maksymmalyhin 4a3fbb1
FIRMessagingRemoteNotificationsProxyTest - remove GULLoggerForceDebug()
maksymmalyhin b390f4f
GULAppDelegateSwizzler - add deprecated `application:didReceiveRemote…
maksymmalyhin 236877d
Merge branch 'master'
maksymmalyhin 3641d35
Merge branch 'master'
maksymmalyhin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
GoogleUtilities/GULAppDelegateSwizzler - tvOS support
- Loading branch information
commit dae75d905c869f8e11476fdca9487b9ba99d58c7
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
|
||
#import "TargetConditionals.h" | ||
|
||
#if TARGET_OS_IOS | ||
#if TARGET_OS_IOS || TARGET_OS_TV | ||
|
||
#import <GoogleUtilities/GULAppEnvironmentUtil.h> | ||
#import <GoogleUtilities/GULLogger.h> | ||
|
@@ -65,14 +65,19 @@ typedef void (*GULRealDidReceiveRemoteNotificationWithCompletionIMP)( | |
static char const *const kGULContinueUserActivityIMPKey = "GUL_continueUserActivityIMP"; | ||
static char const *const kGULHandleBackgroundSessionIMPKey = "GUL_handleBackgroundSessionIMP"; | ||
static char const *const kGULOpenURLOptionsIMPKey = "GUL_openURLOptionsIMP"; | ||
|
||
#if TARGET_OS_IOS | ||
static char const *const kGULOpenURLOptionsSourceAnnotationsIMPKey = | ||
"GUL_openURLSourceApplicationAnnotationIMP"; | ||
static char const *const kGULRealDidReceiveRemoteNotificationIMPKey = | ||
"GUL_didReceiveRemoteNotificationIMP"; | ||
#endif // TARGET_OS_IOS | ||
|
||
static char const *const kGULRealDidRegisterForRemoteNotificationsIMPKey = | ||
"GUL_didRegisterForRemoteNotificationsIMP"; | ||
static char const *const kGULRealDidFailToRegisterForRemoteNotificationsIMPKey = | ||
"GUL_didFailToRegisterForRemoteNotificationsIMP"; | ||
static char const *const kGULRealDidReceiveRemoteNotificationIMPKey = | ||
"GUL_didReceiveRemoteNotificationIMP"; | ||
|
||
static char const *const kGULRealDidReceiveRemoteNotificationWithCompletionIMPKey = | ||
"GUL_didReceiveRemoteNotificationWithCompletionIMP"; | ||
|
||
|
@@ -354,6 +359,7 @@ + (void)createSubclassWithObject:(id<UIApplicationDelegate>)anObject { | |
fromClass:realClass]; | ||
NSValue *continueUserActivityIMPPointer = [NSValue valueWithPointer:continueUserActivityIMP]; | ||
|
||
#if TARGET_OS_IOS | ||
// For application:openURL:sourceApplication:annotation: | ||
SEL openURLSourceApplicationAnnotationSEL = @selector(application: | ||
openURL:sourceApplication:annotation:); | ||
|
@@ -367,6 +373,19 @@ + (void)createSubclassWithObject:(id<UIApplicationDelegate>)anObject { | |
NSValue *openURLSourceAppAnnotationIMPPointer = | ||
[NSValue valueWithPointer:openURLSourceApplicationAnnotationIMP]; | ||
|
||
// For application:didReceiveRemoteNotification: | ||
SEL didReceiveRemoteNotificationSEL = @selector(application:didReceiveRemoteNotification:); | ||
[GULAppDelegateSwizzler addInstanceMethodWithSelector:didReceiveRemoteNotificationSEL | ||
fromClass:[GULAppDelegateSwizzler class] | ||
toClass:appDelegateSubClass]; | ||
GULRealDidReceiveRemoteNotificationIMP didReceiveRemoteNotificationIMP = | ||
(GULRealDidReceiveRemoteNotificationIMP) | ||
[GULAppDelegateSwizzler implementationOfMethodSelector:didReceiveRemoteNotificationSEL | ||
fromClass:realClass]; | ||
NSValue *didReceiveRemoteNotificationIMPPointer = | ||
[NSValue valueWithPointer:didReceiveRemoteNotificationIMP]; | ||
#endif // TARGET_OS_IOS | ||
|
||
// For application:handleEventsForBackgroundURLSession:completionHandler: | ||
SEL handleEventsForBackgroundURLSessionSEL = @selector(application: | ||
handleEventsForBackgroundURLSession:completionHandler:); | ||
|
@@ -430,18 +449,6 @@ + (void)createSubclassWithObject:(id<UIApplicationDelegate>)anObject { | |
[NSValue valueWithPointer:didReceiveRemoteNotificationWithCompletionIMP]; | ||
} | ||
|
||
// For application:didReceiveRemoteNotification: | ||
SEL didReceiveRemoteNotificationSEL = @selector(application:didReceiveRemoteNotification:); | ||
[GULAppDelegateSwizzler addInstanceMethodWithSelector:didReceiveRemoteNotificationSEL | ||
fromClass:[GULAppDelegateSwizzler class] | ||
toClass:appDelegateSubClass]; | ||
GULRealDidReceiveRemoteNotificationIMP didReceiveRemoteNotificationIMP = | ||
(GULRealDidReceiveRemoteNotificationIMP) | ||
[GULAppDelegateSwizzler implementationOfMethodSelector:didReceiveRemoteNotificationSEL | ||
fromClass:realClass]; | ||
NSValue *didReceiveRemoteNotificationIMPPointer = | ||
[NSValue valueWithPointer:didReceiveRemoteNotificationIMP]; | ||
|
||
// Override the description too so the custom class name will not show up. | ||
[GULAppDelegateSwizzler addInstanceMethodWithDestinationSelector:@selector(description) | ||
withImplementationFromSourceSelector:@selector(fakeDescription) | ||
|
@@ -457,8 +464,16 @@ + (void)createSubclassWithObject:(id<UIApplicationDelegate>)anObject { | |
objc_setAssociatedObject(anObject, &kGULOpenURLOptionsIMPKey, openURLOptionsIMPPointer, | ||
OBJC_ASSOCIATION_RETAIN_NONATOMIC); | ||
} | ||
|
||
#if TARGET_OS_IOS | ||
objc_setAssociatedObject(anObject, &kGULOpenURLOptionsSourceAnnotationsIMPKey, | ||
openURLSourceAppAnnotationIMPPointer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); | ||
|
||
objc_setAssociatedObject(anObject, &kGULRealDidReceiveRemoteNotificationIMPKey, | ||
didReceiveRemoteNotificationIMPPointer, | ||
OBJC_ASSOCIATION_RETAIN_NONATOMIC); | ||
#endif // TARGET_OS_IOS | ||
|
||
objc_setAssociatedObject(anObject, &kGULRealDidRegisterForRemoteNotificationsIMPKey, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, that's definitely an option! Feel free to refactor that in a separate PR :) |
||
didRegisterForRemoteNotificationsIMPPointer, | ||
OBJC_ASSOCIATION_RETAIN_NONATOMIC); | ||
|
@@ -468,9 +483,7 @@ + (void)createSubclassWithObject:(id<UIApplicationDelegate>)anObject { | |
objc_setAssociatedObject(anObject, &kGULRealDidReceiveRemoteNotificationWithCompletionIMPKey, | ||
didReceiveRemoteNotificationWithCompletionIMPPointer, | ||
OBJC_ASSOCIATION_RETAIN_NONATOMIC); | ||
objc_setAssociatedObject(anObject, &kGULRealDidReceiveRemoteNotificationIMPKey, | ||
didReceiveRemoteNotificationIMPPointer, | ||
OBJC_ASSOCIATION_RETAIN_NONATOMIC); | ||
|
||
objc_setAssociatedObject(anObject, &kGULRealClassKey, realClass, | ||
OBJC_ASSOCIATION_RETAIN_NONATOMIC); | ||
|
||
|
@@ -652,6 +665,8 @@ - (BOOL)application:(UIApplication *)application | |
return returnedValue; | ||
} | ||
|
||
#if TARGET_OS_IOS | ||
|
||
- (BOOL)application:(UIApplication *)application | ||
openURL:(NSURL *)url | ||
sourceApplication:(NSString *)sourceApplication | ||
|
@@ -682,6 +697,8 @@ - (BOOL)application:(UIApplication *)application | |
return returnedValue; | ||
} | ||
|
||
#endif // TARGET_OS_IOS | ||
|
||
#pragma mark - [Donor Methods] Network overridden handler methods | ||
|
||
#pragma clang diagnostic push | ||
|
@@ -812,6 +829,8 @@ - (void)application:(UIApplication *)application | |
} | ||
} | ||
|
||
#if TARGET_OS_IOS | ||
|
||
- (void)application:(UIApplication *)application | ||
didReceiveRemoteNotification:(NSDictionary *)userInfo { | ||
NSValue *didReceiveRemoteNotificationIMPPointer = | ||
|
@@ -833,6 +852,8 @@ - (void)application:(UIApplication *)application | |
} | ||
} | ||
|
||
#endif // TARGET_OS_IOS | ||
|
||
+ (void)proxyAppDelegate:(id<UIApplicationDelegate>)appDelegate { | ||
if (![appDelegate conformsToProtocol:@protocol(UIApplicationDelegate)]) { | ||
GULLogNotice( | ||
|
@@ -911,4 +932,4 @@ + (void)resetProxyOriginalDelegateOnceToken { | |
|
||
@end | ||
|
||
#endif // TARGET_OS_IOS | ||
#endif // TARGET_OS_IOS || TARGET_OS_TV |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tejasd Is this required that if I use GULAppDelegateSwizzler and I need to swizzle some methods under UIApplicationDelegate, my class must follow the protocol and implement the methods here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the current design, yes. If that's a blocker we can create our own protocol, say GULAppDelegate which can be platform agnostic.