diff options
author | Chen Liang <chliang@google.com> | 2018-07-09 14:33:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-09 14:33:41 -0700 |
commit | 954e4d5df13b14aee9c1112db67a23729d12acfd (patch) | |
tree | debab82666deb5d7ff1e99d55f5dba749db1ffb1 /Firebase/Messaging/FIRMessaging.m | |
parent | bd69fae81077dd1107e4abe8a8722cb3d8a5fb29 (diff) |
avoid calling [UIApplication sharedApplication] in app extensions (#1503)
Diffstat (limited to 'Firebase/Messaging/FIRMessaging.m')
-rw-r--r-- | Firebase/Messaging/FIRMessaging.m | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Firebase/Messaging/FIRMessaging.m b/Firebase/Messaging/FIRMessaging.m index 5dd7004..a92f185 100644 --- a/Firebase/Messaging/FIRMessaging.m +++ b/Firebase/Messaging/FIRMessaging.m @@ -378,7 +378,10 @@ NSString *const kFIRMessagingPlistAutoInitEnabled = }); return; } - UIApplication *application = [UIApplication sharedApplication]; + UIApplication *application = FIRMessagingUIApplication(); + if (!application) { + return; + } id<UIApplicationDelegate> appDelegate = application.delegate; SEL continueUserActivitySelector = @selector(application:continueUserActivity:restorationHandler:); @@ -611,7 +614,11 @@ NSString *const kFIRMessagingPlistAutoInitEnabled = // We require a token from Instance ID NSString *token = self.defaultFcmToken; // Only on foreground connections - UIApplicationState applicationState = [UIApplication sharedApplication].applicationState; + UIApplication *application = FIRMessagingUIApplication(); + if (!application) { + return NO; + } + UIApplicationState applicationState = application.applicationState; BOOL shouldBeConnected = _shouldEstablishDirectChannel && (token.length > 0) && applicationState == UIApplicationStateActive; |