Skip to content

Commit f95ee89

Browse files
authored
Merge pull request #1666 from firebase/bs-messaging-category
Remove Messaging FIRApp Class Category
2 parents 688465a + 515e51b commit f95ee89

File tree

4 files changed

+46
-131
lines changed

4 files changed

+46
-131
lines changed

Example/Firebase.xcodeproj/project.pbxproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6631,12 +6631,12 @@
66316631
BUNDLE_LOADER = "$(TEST_HOST)";
66326632
CLANG_ANALYZER_NONNULL = YES;
66336633
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
6634+
DEBUG_INFORMATION_FORMAT = dwarf;
6635+
DEVELOPMENT_TEAM = "";
66346636
HEADER_SEARCH_PATHS = (
66356637
"$(inherited)",
66366638
"${PODS_ROOT}/Headers/Private",
66376639
);
6638-
DEBUG_INFORMATION_FORMAT = dwarf;
6639-
DEVELOPMENT_TEAM = "";
66406640
INFOPLIST_FILE = "Core/Tests/Tests-Info.plist";
66416641
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
66426642
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@@ -6653,13 +6653,13 @@
66536653
BUNDLE_LOADER = "$(TEST_HOST)";
66546654
CLANG_ANALYZER_NONNULL = YES;
66556655
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
6656+
COPY_PHASE_STRIP = NO;
6657+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
6658+
DEVELOPMENT_TEAM = "";
66566659
HEADER_SEARCH_PATHS = (
66576660
"$(inherited)",
66586661
"${PODS_ROOT}/Headers/Private",
66596662
);
6660-
COPY_PHASE_STRIP = NO;
6661-
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
6662-
DEVELOPMENT_TEAM = "";
66636663
INFOPLIST_FILE = "Core/Tests/Tests-Info.plist";
66646664
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
66656665
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";

Firebase/Messaging/FIRMessaging+FIRApp.h

Lines changed: 0 additions & 24 deletions
This file was deleted.

Firebase/Messaging/FIRMessaging+FIRApp.m

Lines changed: 0 additions & 102 deletions
This file was deleted.

Firebase/Messaging/FIRMessaging.m

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@
3131
#import "FIRMessagingLogger.h"
3232
#import "FIRMessagingPubSub.h"
3333
#import "FIRMessagingReceiver.h"
34+
#import "FIRMessagingRemoteNotificationsProxy.h"
3435
#import "FIRMessagingRmqManager.h"
3536
#import "FIRMessagingSyncMessageManager.h"
3637
#import "FIRMessagingUtilities.h"
3738
#import "FIRMessagingVersionUtilities.h"
39+
#import "FIRMessaging_Private.h"
3840

3941
#import <FirebaseCore/FIRAppInternal.h>
4042
#import <FirebaseInstanceID/FirebaseInstanceID.h>
@@ -190,6 +192,45 @@ - (void)dealloc {
190192

191193
#pragma mark - Config
192194

195+
+ (void)load {
196+
[[NSNotificationCenter defaultCenter] addObserver:self
197+
selector:@selector(didReceiveConfigureSDKNotification:)
198+
name:kFIRAppReadyToConfigureSDKNotification
199+
object:nil];
200+
}
201+
202+
+ (void)didReceiveConfigureSDKNotification:(NSNotification *)notification {
203+
NSDictionary *appInfoDict = notification.userInfo;
204+
NSNumber *isDefaultApp = appInfoDict[kFIRAppIsDefaultAppKey];
205+
if (![isDefaultApp boolValue]) {
206+
// Only configure for the default FIRApp.
207+
FIRMessagingLoggerDebug(kFIRMessagingMessageCodeFIRApp001,
208+
@"Firebase Messaging only works with the default app.");
209+
return;
210+
}
211+
212+
NSString *appName = appInfoDict[kFIRAppNameKey];
213+
FIRApp *app = [FIRApp appNamed:appName];
214+
[[FIRMessaging messaging] configureMessaging:app];
215+
}
216+
217+
- (void)configureMessaging:(FIRApp *)app {
218+
// Swizzle remote-notification-related methods (app delegate and UNUserNotificationCenter)
219+
if ([FIRMessagingRemoteNotificationsProxy canSwizzleMethods]) {
220+
NSString *docsURLString = @"https://firebase.google.com/docs/cloud-messaging/ios/client"
221+
@"#method_swizzling_in_firebase_messaging";
222+
FIRMessagingLoggerNotice(kFIRMessagingMessageCodeFIRApp000,
223+
@"FIRMessaging Remote Notifications proxy enabled, will swizzle "
224+
@"remote notification receiver handlers. If you'd prefer to manually "
225+
@"integrate Firebase Messaging, add \"%@\" to your Info.plist, "
226+
@"and set it to NO. Follow the instructions at:\n%@\nto ensure "
227+
@"proper integration.",
228+
kFIRMessagingRemoteNotificationsProxyEnabledInfoPlistKey,
229+
docsURLString);
230+
[FIRMessagingRemoteNotificationsProxy swizzleMethods];
231+
}
232+
}
233+
193234
- (void)start {
194235
// Print the library version for logging.
195236
NSString *currentLibraryVersion = FIRMessagingCurrentLibraryVersion();

0 commit comments

Comments
 (0)